A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: playing a YouTube video

  1. #1
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632

    playing a YouTube video

    Google has released the AS3 API for YouTube.
    This means you can embed a chromeless player now inside your AS3 based KoolMoves project. Here's an example
    Code:
    var player:Object;
    
    var yt_loader:Loader = new Loader();
    yt_loader.contentLoaderInfo.addEventListener(Event.INIT, onYTLoaderInit);
    yt_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
    
    function onYTLoaderInit(e:Event):void {
    
        // position the loader that contains the youtube player at (20, 20)
        
        yt_loader.x = 20;
        yt_loader.y = 20;
        addChild(yt_loader);
        
        // set the event listeners
        
        player = yt_loader.content;
        player.addEventListener("onReady", onPlayerReady);
        player.addEventListener("onError", onPlayerError);
    
    }
    
    function onPlayerError(e:Event):void {
        trace("player error:", e.data);
    }
    
    function onPlayerReady(e:Event):void {
    
    	// setup the player
    
    	player.setSize(320, 240);
    	player.setVolume(70);
    	
    	// load the video
    	// replace the first parameter with your own video id
    	
    	player.loadVideoById("AnWkTRnUuTU", 0, "default");
    
    }
    For the complete API reference, see http://code.google.com/intl/nl/apis/...reference.html
    Last edited by w.brants; 10-15-2009 at 09:22 AM.

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Hey that's pretty sweet

  3. #3
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    That's pretty cool! Thanks for sharing Wilbert!

  4. #4

  5. #5
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    A very nice example Chris.
    How did you do the search ?

  6. #6
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Using the API pages you linked to....specifically this one:

    http://code.google.com/intl/nl/apis/...arameters.html

    You can squeeze out up to 50 results and then it's just a matter of using some string manipulation/extraction and xml building to create a playlist. Really impressed with this one Wilbert. It is quite simply a great addition to the already outstanding arsenal of goodies AS3 support has offered Koolmoves users.

  7. #7
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Thanks a lot Chris.
    I didn't realize it was relatively easy. Maybe I could add a feature that sets a playlist of all videos of a specific YouTube user.

  8. #8

  9. #9
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    I like the new example you created Chris.
    The search works very nice and the info you can view about a video works great.

  10. #10
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I'll be giving away that source later today. I will be coding a YouTube bandit based on SWFStudio and Koolmoves and will also post that for download once I build it.

    You know........ I don't take for granted how kind you and Bob are to me. You both always keep me in the loop about new things, keep sending me beta's even though on face value I may be inactive (but am usually doing something that may not be reflected by the CODEX or forum activity), listen to suggestions and feature requests I make and much more. I've been online friends with you both for a long time now and hope you both know it is my pleasure to be aquainted with you, watch you both constantly display your brilliance through your coding and an honor to call you both friends. Much like my own children, Koolmoves is like a child to me that I have watched grow with pride. You should both be very proud of what you have accomplished.

  11. #11
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632

  12. #12
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    The Source code is in the KM-CODEX downloads. Once Wilbert and Bob distribute the new classes (Mediaplayer and PlaylistCreator) it will work for7.2.2 users upon opening

  13. #13
    Member
    Join Date
    Jul 2009
    Posts
    37
    Once Wilbert and Bob distribute the new classes
    When is that suppose to happen?

    Steven

  14. #14
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by shx View Post
    When is that suppose to happen?
    KoolMoves 7.3 or if you are a beta tester, the most recent beta.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center