Saturday, July 8, 2006

youTube Search, powered by Flex

Jan 2007: Due to abrupt youTube.com security policy change, my youTube App doesnt work anymore. Possibly due to an exploit, youTube abruptly changed their crossdomain.xml file to only allow access from the youtube.com domain. As a result, YouTube developer API calls no longer work if the SWF exists in a non-youtube.com domain

So here it is, I have finally done it... a day of hard work, coupled with a couple of days of research :). I have the youTube search Tool, ready to go! You might have to de-activate the popUp blocker on your browser to see this application. I have made an alternate version for those who do not know how to do that. This application requires you to have FlashPlayer9. Download FlashPlayer 9 here and then Click on the links below.


This is the first public application that I am posting, so I'm really excited about it. It was an awsome experience building this application. The initial time was spent in the layout, look & feel of the app (which i think is still "too plain"). Then came the REST calls and parsing the incoming XML to suit my needs.

Then came a heart-breaker for me, which made me almost ditch my application. Due to some chaps ripping flvs (Flash Videos) off youTube (read it here), youTube had reworked their site inorder not to expose the flvs. So now i couldn't play them in my app... Directly.

But a programmer always finds workarounds to problems. Those who frequent youtube know that youtube provides a html code snippet, allowing you to embed it into your blog. In the code, there is a text like "tLuLE3jm1VU" is the only thing that varies across videos (and its called the video id). I had the video id of the videos i wanted, thanks to the youTube API. So i wrote a small PHP script to take the id as input and then generate the html page for my video.

I would then popUp this window as an html page (of a specified size) through JavaScript which was called inturn from my application using the Flash External Interface API. And hola... it worked... But my woes wouldnt end there. This workaround came at the cost of perfomance in my app and some of the thumbnails were not loading properly after the external interface call.

Then our very own Manish came to the rescue... Manish had written a youTube Featured video player back in March and had now reworked it to extract the flv out of the id again... Then things were all on a platter for me... I could now use Manish's code snippets, extract the flv file and play it in my own Video Display inside FLEX.

A bit of exceptional handling and try-catching :) and the application was ready to rock. So presenting to you....

If you find any bugs or issues, mail it to me at raghunath.rao at gmail dot com
Anyone wants to look at the code, you can find it here...

I'm Addicted to You Tube & its API

You Tube is a fantastic site... It has captivated my imagination for sometime now, that I was glued to it. A novel idea of uploading videos and then making it freely "searchable" or blog-appendable for anyone. You can see a whole lot of You Tube videos in my Media Blog... But one thing about youtube I did not like was its searchability and the ease of use to find a video that you are looking for (by user, by tag...etc).

So, I have been wanting to write a search tool for youTube for a long time now. And then i chanced on the youTube API. Its a set of very simple REST (click here to know about REST) calls that would return me useful search info like search by tags, username... etc in a simple, ready to use XML Format!!

I could now use this data in my Flex Application & write a search tool... So I was well on my way to write a youTube Search tool... That in the next post..

Before i sign off, here's a video I found on youTube that defines my state of affairs with youTube in the past few days.


I'm addicted To youTube