iphone开发人员从MPMoviePlayerController获取视频缩略图(帧)

iphone开发人员从MPMoviePlayerController获取视频缩略图(帧),iphone,Iphone,每一个我试图从视频url获取视频帧或缩略图,但没有成功,下面是我的代码 - (void)viewDidLoad { thumbnailimg = [[UIImageView alloc]init]; movie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=ec9KXrpYvzk"]]; //UIImag

每一个我试图从视频url获取视频帧或缩略图,但没有成功,下面是我的代码

- (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都没有启动。告诉我我做错了什么以及如何纠正它,thanx提前告诉Saad

使用MPMoviePlayerController从YouTube读取视频是不可能的,请尝试使用其他视频(从m3u8播放列表或MP4文件)。

使用MPMoviePlayerController从YouTube读取视频是不可能的,请尝试使用其他视频(来自m3u8播放列表或MP4文件)。

只是想告诉大家,时间应该以浮点形式提供,而不是int。 替换:

NSNumber * time =[NSNumber numberWithInt:10];
与:

也许会解决一些问题


类似的回答:

只是想告诉大家时间应该以浮点形式提供,而不是int。 替换:

NSNumber * time =[NSNumber numberWithInt:10];
与:

也许会解决一些问题


类似的回答:

Thanx Julien但我有YouTube视频链接,我的要求是我必须在表格视图单元格n中显示视频标题及其缩略图,当用户点击它时,我将播放视频,所以请告诉我是否有任何解决方法。查看YouTube Web服务,您可能会找到解决方案。Thanx Julien但我有you tube视频链接,我的要求是,我必须在表格视图单元格n中显示视频标题及其缩略图,当用户点击它时,我将播放视频,所以请告诉我是否有任何解决方法。查看YouTube Web服务,您可能会找到解决方案。