0

在我的应用程序中,我录制了视频并在 iphone 中显示缩略图。一切正常。

但我的缩略图不显示视频时间长度。

我从以下链接获得了代码:

拇指指甲图片

//my code

NSURL *videoURL = [NSURL fileURLWithPath:url];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

        UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

我该如何解决这个问题?

4

1 回答 1

2
   NSURL *videoURL = [NSURL fileURLWithPath:url];

   MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

   UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showDuration:) name:MPMovieDurationAvailableNotification object:player];


-(void)showDuration:(NSNotification*)notif
 {
MPMoviePlayerController *player = (MPMoviePlayerController*)[notif object];
NSLog(@"content play length is %g seconds", player.duration);
  }
于 2013-02-19T07:19:39.910 回答