I did some projects for some of my clients where I had to use the YouTube API to load videos in flash from the YouTube website. I remember I spent a lot of time trying to find a working example that I could use on my project. I first tried to work with the ActionScript 3 chromeless YouTube API (a friend of mine did a fast example using Flex and this API) but just when I thought the project is done, I got a message back from the client saying that he can not use the player because it’s working through some JavaScript code and his users can’t embed the player on myspace, facebook and stuff like that. Then I had to start form scratch but this time I had to make it work with ActionScript 2 (at the time there was very little documentation about this on code.google.com)… after some hours of research and experiments I finally made the YouTube player in ActionScript 2 and I delivered the project without problems. Now I want to share with all of you the code that I used to get a project like this done. I have uploaded a zip archive with all the files you need if you want to get started with a similar project.
Click here if you want to see how this YouTube Playlist app looks like π
YouTube Playlist (22.3 KiB, 4,875 hits)
Here you can see some of the projects I did using this API:
meeetv.com project
actionext.com project, I did 4 players for this client with 4 different skins and very similar code on all 4 of them.
I didn’t know you could make your own player for YouTube. Thanks for sharing. π
great player. I would like to make it with the original chrome. I’m making a player for a client that will have:
1) scrolling thumbnails of the videos (I can get this done)
2) and hopefully the ability to get metatag data, ability to sort content by latest videos, most popular, highest rated.
If you have any suggestions for 2) please let me know and thanks for the great examples.
ray…
Here you can read the YouTube API documentation and see if you can find any info that will help you with your project:
http://code.google.com/apis/youtube/flash_api_reference.html
Hi Vamapaull. Your player is nice, is there anyway to make the video larger? Thanks..
@aaron
Yes, sure… there is a way π
i love your cryptic answer, and i was very confident that i could figure out how to make the video larger, but i’m stumped! can you give me a hand with how to make the video come out larger?
Main timeline ActionScript 2 code:
line 15
ytplayer.setSize(370, 240);
370 is the width number
240 is the height number
I just found out it’s necessary to insert a second “ytplayer.setSize(370, 240);” line inside the onEnterFrame in order to make Flash resize video. I was trying to leave it in HQ size (960×505) but I couldn’t. So, instead of making it set size with onLoad, I inserted it inside the onEnterFrame. It worked perfectly!
Dunno if this problem was only with me, but who’s with this problem, should try it!
BTW, thanks vamapaull for sharing it with us! It really came in handy!
Somehow the player isn’t playing the YouTube videos anymore. I’ve checked your demonstration page and the same error happens. I’ve tested on Firefox and Safari. With Safari, I’ve checked the error in Window > Activity, and it displays something like “require payment”. What does it mean?
@dsaportfolio – it’s working fine here… make sure you have valid youtube video ID’s in the playlist.
hello friend, I would like to not have player playlist, showing a single video much will it cost I like your example but I do not understand
Hi,
Nice work.
I need your help for changing the loading method.
In fact i don’t want to load an xml file but simply read an youtube ID put in a textfield on a stage.
ex. : mytextfield.text=”5SaFTm2bcac”
how can i play it with your player.
Thx
@crazyboy – You can buy one from my ActiveDen profile
Would love to see how this works but I’m getting unexpected file format when I try to open it in Flash8 pro… is it saved as a higher version?
Thanks for sharing your knowledge.
I have a question.
Why do I get the message “Unexpected File Format” when trying to open the. Fla?
P.D.: I have Flash 8.
Greetings and thanks again.
That’s because the file is not saved for Flash 8. Right now I’m in vacation so I can’t make an update. Hopefully you’ll upgrade your Flash IDE or find a friend with Flash CS3 and ask him to save the FLA file for Flash 8.
Thanks for sharing!!
Hi paull. i had downloade your file,but when i test play,why the video not show?
need your quick response ASAP.
thanks
regards
Knowing that you need my quick response, here it is: ActionScript 2 is no longer supported by YouTube. The ActionScript 2.0 Player API was officially deprecated on October 14, 2009.
thanks paulll. for your advice :D.
i get the new issue,i can embed youtube video with as2 ,but.when i test movieclip ,theres generate a SWD File too.and i try to upload in server with put both file in server,but the video not showing up.why is it?
where as when i test in flash with ( ctrl + enter ) the video was showing.
Thanks
I can’t answer your question. If the AS2 YouTube API is not supported anymore, I don’t know why you would still even try to work with that API. Just use the AS3 API.