我已设法从 youtube 加载缩略图,但如何选择每个视频存在的六个缩略图之一?
<media:thumbnail url='http://i.ytimg.com/vi/dTI0KDuQl_4/default.jpg' height='90' width='120' time='00:02:42' yt:name='default'/>
<media:thumbnail url='http://i.ytimg.com/vi/dTI0KDuQl_4/mqdefault.jpg' height='180' width='320' yt:name='mqdefault'/>
<media:thumbnail url='http://i.ytimg.com/vi/dTI0KDuQl_4/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/>
<media:thumbnail url='http://i.ytimg.com/vi/dTI0KDuQl_4/1.jpg' height='90' width='120' time='00:01:21' yt:name='start'/>
<media:thumbnail url='http://i.ytimg.com/vi/dTI0KDuQl_4/2.jpg' height='90' width='120' time='00:02:42' yt:name='middle'/>
<media:thumbnail url='http://i.ytimg.com/vi/dTI0KDuQl_4/3.jpg' height='90' width='120' time='00:04:03' yt:name='end'/>
例如,我想要第三个(hqdefault)。
我使用 mwfeedparser 尝试了以下操作:
else if ([currentPath isEqualToString:@"/feed/entry/media:group/media:thumbnail"]) {
NSArray *urlArray = [currentElementAttributes objectForKey:@"url"];
item.thumbnail = urlArray;
processed = YES;
}
在我的视图控制器中,我输入了:
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[item.thumbnail objectAtIndex:3] URLString]]];
cell.videoThumbnail.image = [UIImage imageWithData:data];
但它一直在崩溃:/