Friday, September 10, 2010

Using YouTube RSS Feeds in TapLynx

If you are using the TapLynx framework to build an application then adding a video feed might very well be a requirement. has an API with gdata (the Google data technology) so that you can turn lists of videos into RSS feeds and TapLynx will work well with them.

The TapLynx support website has a few suggestions for how to work with the gdata feeds. Once you have created a playlist or if you want all of the videos uploaded by a user you can get set up pretty quickly.

I recently wanted to go a little beyond that as I wanted to create some feeds that query YouTube and return whichever videos match my query. The Google data api allows for me to create a url that contains my search parameters and it will return an rss feed for TapLynx. If I wanted to get five videos that pertain to Jimi Hendrix, I could use this URL
The "q" parameter is where I can put in my search terms. The "max-results" parameter is how I can constrain the number of videos returned. This url will function and it will return me five Hendrix clips from YouTube. There is only one problem. Three of the clips are not encoded for the iPhone and they won't play on the iPhone.

All YouTube videos by default are encoded to play in the Flash player. Many (but not all) videos have alternate encodings that YouTube will use when an iPhone or HTML5 device or other non-Flash device asks to play them. Thankfully there is a format parameter that we can add to our URLs to return only videos that provide the alternate formatting. The default format for all YouTube videos is "5". So the flash version of each video is denoted by a "5". The iPhone would like to have things that are designated with a format of "6". So, using our example above we can just add a formatting parameter and feel secure that all of the videos that are being returned can be played on an iOS device. Our Hendrix example now looks like
and it returns five video clips (three that were in the original list and two that replace the ones that only have a Flash version) all of which will play on an iPhone.

So, if you are trying to generate rss feeds of YouTube videos for an iPhone application hopefully this will help you ensure that all of the videos play.

1 comment:

Juan Villanueva said...

Thanks for this Walter.

Just a quick question: Is there a way to play the Youtube video right after tap it from the feeds list on the iPhone screen, just like the discoverynews example, without have to go through that extra step of touching the thumb that is shown in the template?


Post a Comment