Hello again,
I’ve gotten to a good level in my Youtube Data API. It’s now ready for use, I would recommend testing it a bit before putting into a production environment, but for experimenting and toying around, works good!
Here is a quick sample:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | package { // first import dependencies (yes you can be more specific.. i'm lazy right now..!) import ca.newcommerce.youtube.data.*; import ca.newcommerce.youtube.events.*; import ca.newcommerce.youtube.feeds.*; import ca.newcommerce.youtube.iterators.*; import ca.newcommerce.youtube.webservice.YouTubeClient; public class ytTest() { // some class variable protected var _ws:YouTubeClient; protected var _requestId:Number; public function ytTest() { // now inside of an init function _ws = YouTubeClient.getInstance(); // register to list to the events you are interested in _ws.addEventListener(StandardVideoFeedEvent.STANDARD_VIDEO_DATA_RECEIVED, doVideos); // do your call.. get the Top Rated videos for the last month, results 1 to 10; it returns a callId _requestId = _ws.getStandardFeed(YouTubeClient.STD_TOP_RATED, YouTubeClient.TIME_MONTH, 1, 10); } protected function doVideos(evt:StandardVideoFeedEvent):void { // we could test to make sure this is the answer to our request by doing the following : // if(_requestId == evt.requestId) // get a reference to the feed containing the videos var feed:VideoFeed = evt.feed; var video:VideoData; while(video = feed.next()) { // trace a newline followed by the video title trace("\nvideo title:"+video.title); // trace the url to use to embed the flash player with this video playing in it.. trace("player url:"+video.swfUrl); // the view count trace("viewCount:"+video.viewCount); // the comment count trace("commentCount:"+video.commentCount); // the duration trace("duration:"+video.duration); // the author trace("author:"+video.authors.first().name); } } } } |
there you go. I hope I didn’t make any mistakes in this code. I will look upon it again on monday as I will be writing a tutorial for this library.
Have a good day!
UPDATE
The project is now available at Google Code, here: http://code.google.com/p/as3-youtube-data-api/
Cheers!
Martin
Hi, im playing with the library and i have a few problems: in this code there is an error with line 48: video.viewCount.
Throws me an error 1010
another question: how can i to accede at the rating. Im trying with this in the while:
video.rating.numRaters but it does’nt work
thanks a lot and sorry for my english
Sometimes there is no data (for example in this case, if there are no ratings) returned by the feed, and it causes errors when trying to access it. It is a pretty serious issue I have to resolve. I am on vacation now, I will take care of it mid-april when I come back home.
Thanks for your comments…
Thanks for your answer and enjoy your vacation
I verified on youtube to see if the video loaded it has rating and it fails too…
its ok this expresion => video.rating.numRaters ??
bye
hi there – awesome work.
I am attempting to pull an xml feed from a youTube user profile into Doug McCunes ‘coverFlow’ Flex component.
I know you have looked at the Flex IDE – do you have any comments/thoughts as to how I might go about this?
cheers,
Jas
Jason: sorry I don’t do Flex.
Martin — great work.
Is it possible, now, to load an .flv from a videoID or do I have to load the .swf which would include all of the the standard next video stuff after the video has played.
Thanks,
Jon
Hi,,,
i just wana know that if it is possible to get video by searching a youtube URL…means if i paste youTube URL into a text input field will it be possible to get all information about that specific page/video…
thanks
Regards
Billy Ash
Hello
I am using this AS3 class library load youtube thumbnail images into my flash interface. Now everything is working fine If I am running this on my computer locally but once I upload it to a live webserver it doesnot load the thumbnail images.
Any idea of why this is not working is this something to do with AS3 security sandbox or other security related isseues?
Thanks for your help in advance
hi, I have the same issue yolo, does somebody know about this?
When I put my site in my server, the player doesn’t show anything, I just can see y my navigator status bar the leyend “… waiting for…..
Thanks for the hard work, probably going to use it for a client project this month.