Show Thumbnail UIImageView

After asking to create my sketch, how can I show it in a UIImageView?

 NSURL *videoURL = [NSURL URLWithString:_videoPathString] ;
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer requestThumbnailImagesAtTimes:[NSArray arrayWithObject:[NSNumber numberWithFloat:2.0f]] timeOption:MPMovieTimeOptionExact];

Any ideas?

+3
source share
2 answers

The method requestThumbnailImagesAtTimes:timeOption:will send a notification MPMoviePlayerThumbnailImageRequestDidFinishNotificationwhen the image request is completed.

Your code that needs a sketch must sign up for this notification using NSNotificationCenter and use the image when it receives the notification.

Example.

Register first for notification : MPMoviePlayerThumbnailImageRequestDidFinishNotification

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(handleThumbnailImageRequestFinishNotification:)
                                             name:MPMoviePlayerThumbnailImageRequestDidFinishNotification
                                           object:nil];

Then request a sketch:

[movie requestThumbnailImagesAtTimes:YOUR_TIMES timeOption:MPMovieTimeOptionExact];

And then get the image:

-(void)handleThumbnailImageRequestFinishNotification:(NSNotification*)notification
{
    NSDictionary *userInfo = [notification userInfo];
    UIImage *image = [userInfo valueForKey:MPMoviePlayerThumbnailImageKey];
}

Source: MPMoviePlayerController class reference

+6
source

:

. , MPMoviePlayerThumbnailImageRequestDidFinishNotification . , . .

, . this

0

All Articles