MPMoviePlayerController showing black empty screen MPMoviePlayerController showing black empty screen ios ios

MPMoviePlayerController showing black empty screen


You need to retain your instance of MPMoviePlayerController i.e. as a property or an instance variable. The reference to the movie player is lost if you do not retain it.


You could try to put [itemMoviePlayerController prepareToPlay]; before the [itemMoviePlayerController play];

The way preferred by Apple to display an only full screen video is to present a modal MPMoviePlayerViewController (as Hollance said).To present it, you should use something like :

 moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL]; [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController]; [itemMoviePlayerController play];

This is documented by Apple here

You can read there that you should keep a reference to your MPMoviePlayerViewController in order to dismiss it later with

[self dismissMoviePlayerViewControllerAnimated:moviePlayerViewController].


I fixed this by putting

@property (strong, nonatomic) MPMoviePlayerController *moviePlayer; 

in my .h file, and calling self.moviePlayer in all my code and it worked!


matomo