每一个我试图得到一个视频网址的视频帧或缩略图,但它没有成功,这里是我的代码iPhone开发从的MPMoviePlayerController
- (void)viewDidLoad {
thumbnailimg = [[UIImageView alloc]init];
movie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=ec9KXrpYvzk"]];
//UIImage *singleFrameImage = [movie thumbnailImageAtTime:10
//timeOption:MPMovieTimeOptionExact];
//thumbnailimg.image = singleFrameImage;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(handleThumbnailImageRequestFinishNotification:)
name:MPMoviePlayerThumbnailImageRequestDidFinishNotification
object:movie];
NSNumber * time =[NSNumber numberWithInt:10];
NSArray *times = [NSArray arrayWithObjects:time,nil];
[movie requestThumbnailImagesAtTimes:times timeOption:MPMovieTimeOptionExact];
[super viewDidLoad];
}
-(void)handleThumbnailImageRequestFinishNotification:(NSNotification*)note
{
NSDictionary *userinfo = [note userInfo];
NSMutableDictionary *event = [NSMutableDictionary dictionary];
NSError* value = [userinfo objectForKey:MPMoviePlayerThumbnailErrorKey];
if (value!=nil)
{
[event setObject:[value description] forKey:@"error"];
}
else
{
UIImage *image = [userinfo valueForKey:MPMoviePlayerThumbnailImageKey];
thumbnailimg.image = image;
}
[event setObject:[userinfo valueForKey:MPMoviePlayerThumbnailTimeKey] forKey:@"time"];
}
连handleThumbnailImageRequestFinishNotification是不开火,plz。告诉我我做错了什么,以及如何纠正它,事先thanx,Regards Saad
感谢名单朱利安,但我有你管的视频链接,我的要求是,我有一个表格视图单元格中显示视频标题以及其缩略图N将用户点击它,我将播放视频,所以PLZ。告诉我是否有任何解决此问题的方法 – 2012-03-01 10:20:19
查看YouTube Web Services,您可能会找到解决方案。 https://developers.google.com/youtube/2.0/developers_guide_jsonc?hl=fr#Retrieving_Playlist_Contents – Julien 2012-03-02 10:49:23