Search code examples
iosmedia-playermpmovieplayercontroller

MPMoviePlayerController: How to turn off sound during requestThumbnailImagesAtTimes:timeOption:


In my app I record a movie, save it to the PhotosAlbum, and request then creation of a thumbnail using the code

self.player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL_];
NSArray *times = @[@(1.1)];
[self.player requestThumbnailImagesAtTimes:times timeOption:MPMovieTimeOptionNearestKeyFrame];  

This works fine, but during the thumbnail creation, MPMoviePlayerController plays the sound of the movie, although the movie is not visible, which is annoying.
How can I turn the sound off just of this particular MPMoviePlayerController? The MPMoviePlayerController class has apparently no property to control this.


Solution

  • Just add this line after creating your player:

    self.player.shouldAutoplay = NO;