MPMoviePlayerController problem at start
-
27-09-2019 - |
Question
I have a problem with MPMoviePlayerController, because when I start it in fullscreen it exists, but the song is still playing. I added the MPMoviePlayerDidExitFullscreenNotification notification and it says that when the video starts playin it exists the full screen. Here's my code:
_multimediaPlayer = [[MPMoviePlayerController alloc] init];
_multimediaPlayer.controlStyle = MPMovieControlStyleDefault;
_multimediaPlayer.initialPlaybackTime = 0;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoPlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoPlayerDidExitFullscreen:)
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoPlayerPlaybackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
NSString *path = [NSString stringWithFormat:@"%@/mag_%d/%@", [FMUtils documentsFolderPathWithFile:nil], _magID, _pageObject.fileName];
if ([FMUtils fileExistsAtPath:path]) {
_multimediaPlayer.contentURL = [NSURL fileURLWithPath:path];
} else {
_multimediaPlayer.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", self.dataURL, _pageObject.fileName]];
}
CGSize objectViewSize = self.frame.size;
_multimediaPlayer.view.frame = CGRectMake(0, 0, objectViewSize.width, objectViewSize.height);
[self addSubview:_multimediaPlayer.view];
if (_pageObject.blink) {
[_multimediaPlayer setFullscreen:YES animated:YES];
}
[_multimediaPlayer play];
Most of the time it happens when the video is not downloaded and it needs to stream it.
Do you have any idea why is this happen?
Solution
Problem solved while I not listen to MPMoviePlayerPlaybackStateDidChangeNotification.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow