Search code examples
iphoneiosmpmovieplayercontroller

how can I request thumbnailImage from MPMoviePlayController while slider


I have a custom UISider control, i send requestThumbnailImagesAtTimes to MPMoviePlayerController when i slider the control.

- (void)sliderPopoverView:(UISlider*)slider
{
    self.currentSliderValue = slider.value;
    [self.moviePlayer requestThumbnailImagesAtTimes:[NSArray arrayWithObject:[NSNumber numberWithDouble:self.currentSliderValue]]
                                             timeOption:MPMovieTimeOptionNearestKeyFrame];
} 

- (void)requestFinishThumbnail:(NSNotification*)notification
{
    UIImage *thumbnailImage = [notification.userInfo objectForKey:MPMoviePlayerThumbnailImageKey];
    if (thumbnailImage) {
        _bottomView.sliderPopover.popover.thumbnailView.image = thumbnailImage;
    }  
}

then I can receive lots of image for show. but main Thread blocked. it's hard to slider the custom control. cost lots of time.


Solution

  • The reason may be that the method

    - (void)sliderPopoverView:(UISlider*)slider
    

    is called every time the slider is moved a little bit. This will cause your MPMoviePlayerController to constantly generate thumbnails. You should probably try to reduce the number of times you call the method that generates thumbnails.