How to get Thumbnail video from GDataFeedYouTubePlaylist

100 views
Skip to first unread message

Alexandre Cruz

unread,
Oct 6, 2011, 11:11:53 PM10/6/11
to Google Data APIs Objective-C Client Library Discussion
I can get thumbnails from video like this:


for (int i=0; i<[feeds entries].count; i++) {
GDataEntryYouTubeVideo *entry = [[feeds entries]
objectAtIndex:i];
NSArray *thumbnails = [[(GDataEntryYouTubeVideo *)entry
mediaGroup] mediaThumbnails];
NSData *data = [NSData dataWithContentsOfURL:[NSURL
URLWithString:[[thumbnails objectAtIndex:0] URLString]]];
[listThumbNails addObject:[UIImage imageWithData:data]];
}

but my feed is from GDataFeedYouTubeVideo object

Now I'm getting videos from a playlist so i have a

GDataFeedYouTubePlaylist which I tried to get thumbnails the same way
but it's not working
anybody knows how to get this to work.

Thanks in advance

Greg Robbins

unread,
Oct 7, 2011, 10:50:48 PM10/7/11
to gdata-objec...@googlegroups.com
I looks like the playlistLink class is currently incorrectly defined for access to that element, as it's wrapped in a media:group.

I'll try to update the library next week to provide access. For now, you'd need to grab the raw XML from the playlistLink entry's unknownChildren array.

Alexandre Cruz

unread,
Oct 8, 2011, 9:38:21 PM10/8/11
to Google Data APIs Objective-C Client Library Discussion
Thanks Greg!

Greg Robbins

unread,
Oct 11, 2011, 4:02:07 PM10/11/11
to gdata-objec...@googlegroups.com
I've updated the library to have a mediaGroup in the parent class of the playlistLink entry. That provides access to the thumbnail.


Mike Malloy

unread,
Feb 13, 2012, 1:06:12 PM2/13/12
to gdata-objec...@googlegroups.com
I'm seeing 2 thumbnail images for the playlist. A small and large image. Is this the expected result?

If I wanted to show thumbnails of a few of the videos inside the playlist - I assume I would have to make an additional call?


my code:

- (void)allPlayListsFetchTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedBase *)aFeed error:(NSError *)error 

    self.youtubeFeed = (GDataFeedYouTubeVideo *)aFeed;

    NSArray *entries = [youtubeFeed entries];     

    for (int i=0; i < [entries count] ; i++) 

     GDataEntryYouTubePlaylistLink *plLink = [entries objectAtIndex:i];

     NSString *htmlLinkString = [[[[[plLink mediaGroup] mediaThumbnails] objectAtIndex:1] URLString]

}

Greg Robbins

unread,
Feb 13, 2012, 1:40:44 PM2/13/12
to gdata-objec...@googlegroups.com
Questions about how to use the YouTube API should be directed to the YouTube API forum,

http://code.google.com/apis/youtube/forum/

Typically, thumbnail fetches are done with a GTMHTTPFetcher instance or with some other http fetch API, as shown in the library's sample applications.

Generally, though, be careful of calling objectAtIndex: with a hardcoded index since it can throw an exception if the array has too few objects.

Fabio Nisci

unread,
Feb 19, 2013, 10:29:46 AM2/19/13
to gdata-objec...@googlegroups.com
Why i receive always NULL?? 

        GDataEntryYouTubePlaylistLink *playlistLink = (GDataEntryYouTubePlaylistLink *)entry;

        NSLog(@"%@", [[playlistLink thumbnail]URLString]);

in xml i can see the links... :(

Reply all
Reply to author
Forward
0 new messages