MPMoviePlayerController

MPMoviePlayerController

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

但是我的缩略图没有显示视频的时间长度。

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

ThumbNail Image

//my code

NSURL *videoURL = [NSURL fileURLWithPath:url];

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

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


我该如何解决?

最佳答案

   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);
  }

关于iphone - 在iPhone中以缩略图显示视频时间长度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14951491/

10-13 02:38