Thursday, 12 September 2013

Objective-C YouTube API - creating video object from URL

Objective-C YouTube API - creating video object from URL

I am given a list of youtube IDs. For each of this IDS, I want to use the
YouTube API to get the title, duration, and thumbnail. I then want the
user to be able to click these thumbnails which takes them to a UIWebView
where they can watch the video.
I'm really stuck on how I can actually create a video object from the ID.
I dont really understand the process in given in Google's sample code,
they get the title based on a playlist. I dont want it based on a
playlist, I want it based on a stand-alone ID or URL.
Using a playlist query, the code uses:
if ([playlistID length] > 0) {
GTLServiceYouTube *service = self.youTubeService;
GTLQueryYouTube *query = [GTLQueryYouTube
queryForPlaylistItemsListWithPart:@"snippet,contentDetails"];
query.playlistId = playlistID;
query.maxResults = 50;
_playlistItemListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLYouTubePlaylistItemListResponse
*playlistItemList,
NSError *error) {
// Callback
_playlistItemList = playlistItemList;
_playlistFetchError = error;
_playlistItemListTicket = nil;
[self updateUI];
}];
}
Which I understand, but looking through GTLQueryYouTube I cant see
anything that relates to a single video. Does anybody have any ideas?
Thanks!

No comments:

Post a Comment