We love choice

Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/423.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Components, How to, Media

Chromeless Youtube Video Player for Flex

Stelian Crisan | 24.12.09 | 6 Comments

Google Buzz

This Flex component allow you to play Youtube movies into you Flex applications and also to be able to customize the look of your player. Actually I put a main movie component and two control sections, one for:  play, stop, mute, unmute and time figures (current second and total number of seconds of the movie); the other one it’s for a visual playing time.

The Youtube API for ActionScript 3.0 (this is for Flash, but it’s working also in Flex) that I used it’s available on Google Code at: http://code.google.com/apis/youtube/flash_api_reference.html. Youtube API for  Flash and ActionScript 2 it’s available at: http://code.google.com/apis/youtube/flash_api_reference_as2.html.

I implement almost all functions available on this API (see Youtube class), but for this example I use just the basics ones. Also you will see that are some skins for buttons, that you can use.

In order to change the Youtube video ID just go to init() function into ChromelessYoutubeVideoPlayer.mxmml file and change the value._youtube it’s player component, and we set to this the ID value, also we add this to the canvas where this will be in design.

//set video ID
_youtube.videoId = "D-wvgqDWjnk";
_playerArea.addChild(_youtube);

The size of played move it’s set for the moment on Youtube class. It’s better to set the sive before movie starts to play, also, using this API, you can set the playback quality (small, medium, large, hd720) and to see the state of the movie ( unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5) ).

private function onPlayerReady(event:Event):void {
// Event.data contains the event parameter, which is the Player API ID
trace("player ready:", Object(event).data);
 
// Once this event has been dispatched by the player, we can use
// cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
// to load a particular YouTube video.
_player = _loader.content;
//load our video ID
_player.loadVideoById(_videoId);
//set movie size
_player.setSize(480,270);
}

I think that it’s better to download the source code, and just try to see how it’s work.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites
ChromelessYoutubeVideoPlayer
ChromelessYoutubeVideoPlayer (1)




Tags: , , , , ,

This post was written by Stelian Crisan

Views: 4075

related

6 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»