AS3 YouTube Chromeless Player in Flash/Flex
The YouTube Chromeless Player works with AS3/ActionScript 3.

The demo shows great examples of the player with just the window canvas (chromeless) from both javascript and inside of flash.
The project is hosted on Google Code [youtubechromelesswrapper-as3]
Looks like they maybe had a contribution for this, so do it where you can.
This is something we’ve been wanting to provide for a while, and the YouTube API team greatly appreciates the work of developer Matthew Richmond of The Chopping Block for making it happen. Thanks Matthew!
Links
- Demo
- Google Code [youtubechromelesswrapper-as3]
- Article about the library
- Download the source (get from google code recommended)
- Javascript Player Reference
Capabilities/API
Public Methods
player.loadVideoById(id:String, startSeconds:Number = 0):void- Loads and plays video based on specified id.
player.cueNewVideo(id:String, startSeconds:Number = 0):void- Loads but does not automatically play video based on specified id.
player.clearVideo():void- Clears currently cued/loaded video.
player.setSize(w:Number, h:Number):void- Sets the size of YouTubePlayer instance.
player.play():void- Plays the currently cued/loaded video.
player.pause():void- Pauses the currently cued/loaded video.
player.stop():void- Stops the currently cued/loaded video.
player.seekTo(seconds:Number):void- Seeks to specified time within the currently cued/loaded video.
player.getPlayerState():String- Returns the current state of the currently cued/loaded video.
player.getBytesLoaded():Number- Returns the value of current bytes loaded of the currently cued/loaded video.
player.getBytesTotal():Number- Returns the value of total bytes loaded of the currently cued/loaded video.
player.getCurrentTime():Number- Returns the current position in time of the currently cued/loaded video.
player.getDuration():Number- Returns the current duration of the currently cued/loaded video.
player.getStartBytes():Number- Returns the start bytes of the currently cued/loaded video.
player.setVolume(newVolume:Number):void- Sets the volume of the currently cued/loaded video.
player.getVolume():Number- Returns the current volume of the currently cued/loaded video.
player.mute():void- Stores the current volume and changes the volume of the currently cued/loaded video to 0.
player.unmute():void- Returns the volume of the currently cued/loaded video to the last stored value when muted.
player.getEmbedCode():String- Returns the current YouTube embed code of the currently cued/loaded video.
player.getVideoUrl():String- Returns the current YouTube video url of the currently cued/loaded video.
Events
YouTubeLoaderEvent.LOADED- Fired once the Chromeless Player has successfully completed loading and is ready to accept operations calls.
YouTubeLoaderEvent.STATE_CHANGE- Fired whenever the player’s state changes. The YouTubeLoader class translates the JavaScript API numbers to their related string values, the YouTubeLoaderEvent class stores the current event in a variable called
state. Possible values are unstarted, ended, playing, paused, buffering, video cued. When the SWF is first loaded, it will broadcast an unstarted event. When the video is cued and ready to play, it will broadcast a video cued event. YouTubeLoaderEvent.IO_ERROR- Fired when an error in the player occurs. There are two error codes possible: 100 is broadcasted when the video requested is not found. This occurs when a video has been removed (for any reason), or it has been marked as private. 101 is broadcasted when the video requested does not allow playback in the embedded players.
Tags: ACTIONSCRIPT, ACTIONSCRIPT3, API, AS3, canvas, chromeless, flv, player, VIDEO, youtube
![*drawlogic – interactive and game development technologies for the web – flash, flex, unity3d, silverlight, javascript [ draw.logic ]](http://farm4.static.flickr.com/3270/3068080918_eeebfbdb01_o.png)
What about a version without javascript at all? For example what if the only media is the swf file and you cannot use ExternalInterface.
Can you play youtube just with flash?
Yeh this library lets you play youtube with just flash without the controls, and with javascript. Either way you can choose.
I don’t understand your answer
Is it possible to play with only an .swf, and no specialized youtube-javascript at all. I.e., is it possible to play from inside flash without external interface? 1
[...] *drawlogic » AS3 YouTube Chromeless Player in Flash/Flex *drawlogic – interactive and game developm… chromeless YouTube player (tags: flex youtube) [...]
Been experiencing a very strange problem for a couple of days.
When loading the YouTubeLoader and an FLVPlayback (or VideoPlayer) in the same project, it works one time out of ten.
In Debug mode (where the youtubeLoader doesn’t work, obviously) the runtime error does not occur), while in Run mode the FLVPlayback/VideoPlayer refuses to play anything after the Youtube player has played smth. and throws the following error:
ArgumentError: Error #2126: NetConnection object must be connected.
at flash.net::NetStream/construct()
at flash.net::NetStream()
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::_createStream()[...\fl\video\VideoPlayer.as:3980]
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::_load()[...\fl\video\VideoPlayer.as:1215]
at fl.video::VideoPlayer/play()[...\fl\video\VideoPlayer.as:971]
I can’t even start it by overring the NetConnection that’s used in the VideoPlayer load method. I declare a new NC… connect it to null (for http streaming) and still the same error.
Probably a Flash Player problem with the NetConnection.
i have no words for this EXCELLENT
The only problem I have it doesn’t work. I tried my best and spent do days to make it work but it didn’t
Can you provide more examples? That I just can open in my Flex Builder and see that the library works?
[...] experience in the browser or composite application. Google wants control to have some response to this type of situation. The video push is a real deal. Google has a cluster of video inventions, which signals to me an [...]
all i want to do is display a youtube video on a flash as3 website that I am creating. Nothing fancy, just make it 50% size and position in lower right corner and play when clicked. Can I do that with AS3 or do I have to back to AS2 for that????
[...] first to see if this problem had been solved already. All I found of importance was TubeLoc and *drawlogic’s players. Both of them use either LocalConnection or ExternallInterface calls to communicate with [...]
So, I would like to use this API- but there are few things that is holding me back.
I understand youtubes securities, but it would be great to get data like formats – (HQ, HD, etc) as well as flv meta data (which can be acquired from a NetStreams.client obj in As3) Any thoughts if it would be possible to obtain that through the API? Been looking through all the APIs out there for the last week – nothing yet except getting a token and pulling the flv directly.
Thanks
ChadAndrewDrobish