MPMoviePlayerController showing black empty screen

Ritika picture Ritika · Dec 8, 2011 · Viewed 23.2k times · Source

I use MPMoviePlayerController to play a local file in my Application Document folder which have I have downloaded for a server URL:

itemMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
 [self.view addSubview:itemMoviePlayerController.view];
 itemMoviePlayerController.fullscreen = YES;
 itemMoviePlayerController.movieSourceType = MPMovieSourceTypeFile;
 itemMoviePlayerController.initialPlaybackTime = -1.0;
 [itemMoviePlayerController play];

When I play .mov file just after I downloaded it, It shows up a black empty screen & app UI is unusable. But if play same local file next time, it plays fine. I even verified playState & localState for MPMoviePlayerController they seems fine. What could be reason for black empty screen?

Answer

Toms Shaji Mathew picture Toms Shaji Mathew · Oct 16, 2012

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.