I am using MPMoviePlayerController to play a small video as an intro video of my app. I have used the following code and this works fine. But the video keeps on playing. end and restarts again. And even when i click on the done button it does not removes the superview. I also want my status bar to be visible and i kept it translucent still no result. I searched on google and stack overflow but still no help. Any help would be much appreciable.
I have called [self playMovie]
method in viewDidAppear
-(void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"avc_intro" ofType:@"mp4"]];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
name:MPMoviePlayerWillExitFullscreenNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController *videoplayer = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:videoplayer];
if ([videoplayer
respondsToSelector:@selector(setFullscreen:animated:)])
{
[videoplayer.view removeFromSuperview];
}
}
Better use this. The MPMoviePlayerController is formally deprecated in iOS 9.