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

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: , , , , , , , , ,

  • http://zproxy.wordpress.com 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?

  • http://drawk.com 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.

  • http://lozanro.flextribe.com/ 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.
    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. :(

  • http://gadgetguild.com 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: www.perkstoveland.com » Using multiple AS2 YouTube Chromeless players in AS3

  • http://www.ChadAndrewDrobish.com 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.

    Thanks
    ChadAndrewDrobish

  • felix_turner

    I posted a demo loading multiple instances of the new YouTube chromeless player and displaying them with Flash 10 native 3D : http://www.airtightinteractive.com/news/?p=379

  • felix_turner

    I posted a demo loading multiple instances of the new YouTube chromeless player and displaying them with Flash 10 native 3D : http://www.airtightinteractive.com/news/?p=379