Tuesday, May 26, 2009

YouTube on Android

From Android supported media formats, we know they only support 3gp and mp4 formats now. There is a particular YouTube application on Android, so I needn't open Android Browser to watch YouTube video. Why I can watch YouTube video without any problem? The reason is from gdata youtube API. When we make a search in YouTube, they can only display mp4 videos files for searching result. I can tell it from android's logs. Below texts are from ddms logcat:

05-27 11:24:06.604: DEBUG/youtube(1603): VideoQuery.run url: /feeds/api/videos?vq=blackandwhite+ep12&format=2&restriction=tw this: com.google.android.youtube.YouTubeActivity$SearchVideoQuery@4364bb78

05-27 11:24:06.604: DEBUG/youtube(1603): YouTubeQueryWorker url:http://gdata.youtube.com/feeds/api/videos?vq=blackandwhite+ep12&format=2&restriction=tw&start-index=1&max-results=9 mStartingIndex: 0

We can find it made a search from below URL and it has some paramaters. The detailed reference guide is here.

q: The q parameter specifies a search query term
format: The format parameter specifies that videos must be available in a particular video format.
restriction: The restriction parameter identifies the IP address that should be used to filter videos that can only be played in specific countries.
start-index: The start-index parameter specifies the index of the first matching result that should be included in the result set.
max-results: The max-results parameter specifies the maximum number of results that should be included in the result set.

Let's verify it in Android Dev Phone!

1. search video from YouTube application: (play successfully!)

2. search video from Android Browser application: (cannot play!)

PS. there is another interesting trick! Based on youtube API, the valid formats are 1, 5, 6. If I click that link from my laptop Firefox browser, I will see nothing. Unless, I change the format to 1, 5, or 6.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.