Using YouTube’s video storage to showcase video content
We were tasked with creating a full Flash website to showcase user-generated video content for a contest that a local restaurant chain (Rosa’s Cafe) is currently running. Any patron to their restaurant is encouraged to film themselves going crazy for Rosa’s. They can upload their video at www.crazyforrosas.com and be eligible for $5000 or a FlipVideo camera.
When tasked with this we decided to use YouTube for the actual storage of the video content. To do this, sign up for a YouTube account and begin uploading some content to begin testing. You can easily take advantage of the YouTube API and RSS feeds to pull the information in Flash.

To access YouTube’s RSS feed, you’ll need to create an intermediary to avoid the cross-domain security protection. We used a PHP script to snag our RSS feed so we can display it on our server.
<?php #readxml.php $file = "http://www.youtube.com/rss/user/username/videos.rss"; $handle = @fopen($file, "r"); if ($handle) { while (!feof($handle)) { echo fgets($handle, 4096); } fclose($handle); } ?>
In Flash, you’ll need to call readxml.php (the above script) as XML and parse it out accordingly. It helps to have a real strong knowledge of XML parsing to get your way through it since there’s a lot of info in the feed that you won’t need. It will give you thumbnail locations, titles, descriptions, video links, etc. One problem that I found is that it’s very difficult to use the YouTube ActionScript API. There is not very much documentation. Opening one video is fine, open another one and Flash will crash. The API says to use the destroy(); command prior to opening another video, but it does not work. I found some help on their forums to help us – but the solution was not some handy ActionScript. It was to use a free component called ToobPlayer. This was most certainly a life saver after spending hours on YouTube’s API and not getting anywhere. The ToobPlayer component can easily use a YouTube video url and be skinned. A big thanks goes out to those folks!
This site also features a full administration panel using CakePHP to administer video submissions and a Flash front-end video upload feature.

