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!



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.
Clears currently cued/loaded video.
player.setSize(w:Number, h:Number):void
Sets the size of YouTubePlayer instance.
Plays the currently cued/loaded video.
Pauses the currently cued/loaded video.
Stops the currently cued/loaded video.
Seeks to specified time within the currently cued/loaded video.
Returns the current state of the currently cued/loaded video.
Returns the value of current bytes loaded of the currently cued/loaded video.
Returns the value of total bytes loaded of the currently cued/loaded video.
Returns the current position in time of the currently cued/loaded video.
Returns the current duration of the currently cued/loaded video.
Returns the start bytes of the currently cued/loaded video.
Sets the volume of the currently cued/loaded video.
Returns the current volume of the currently cued/loaded video.
Stores the current volume and changes the volume of the currently cued/loaded video to 0.
Returns the volume of the currently cued/loaded video to the last stored value when muted.
Returns the current YouTube embed code of the currently cued/loaded video.
Returns the current YouTube video url of the currently cued/loaded video.


Fired once the Chromeless Player has successfully completed loading and is ready to accept operations calls.
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.
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: , , , , , , , , ,

  • zproxy

    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?

  • drawk

    Yeh this library lets you play youtube with just flash without the controls, and with javascript. Either way you can choose.

  • Bobby

    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

  • Pingback: leg med nye medier. Eller noget.

  • Laurenţiu Lozan

    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.

    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. :(

  • syed shams

    i have no words for this EXCELLENT

  • Paul

    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?

  • Pingback: Google and Video Playing Technology : Beyond Search

  • http://none kevin herrod

    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????

  • Pingback: » Using multiple AS2 YouTube Chromeless players in AS3

  • ChadAndrewDrobish

    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.


  • felix_turner

    I posted a demo loading multiple instances of the new YouTube chromeless player and displaying them with Flash 10 native 3D :

  • felix_turner

    I posted a demo loading multiple instances of the new YouTube chromeless player and displaying them with Flash 10 native 3D :