0

In my app, I recorded the video & also displaying the thumbnail Image in iphone. It all works fine.

But my thumbnail image is not shows the video time length.

I got the code from following link:

ThumbNail Image

//my code

NSURL *videoURL = [NSURL fileURLWithPath:url];

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

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

How can i solve this?

Community
  • 1
  • 1
user1673099
  • 3,293
  • 7
  • 26
  • 57

1 Answers1

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);
  }
Gaurav Patel
  • 957
  • 1
  • 6
  • 16
  • use notfication center with MPMovieDurationAvailableNotification – Gaurav Patel Feb 19 '13 at 07:35
  • 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]; – Gaurav Patel Feb 19 '13 at 07:41
  • -(void)showDuration:(NSNotification*)notif { MPMoviePlayerController *player = (MPMoviePlayerController*)[notif object]; NSLog(@"content play length is %g seconds", player.duration); } – Gaurav Patel Feb 19 '13 at 07:42