我遇到了MPMoviePlayerController的问题,因为当我在全屏启动时它存在,但是歌曲仍在播放。我添加了MPMoviePlayerDidExitFullscreenNotification通知,它说当视频开始播放时它存在全屏。这是我的代码:
_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];
大多数情况下,当视频未下载且需要对其进行流式传输时会发生这种情况。
你知道为什么会这样吗?
答案 0 :(得分:0)
我不听MPMoviePlayerPlaybackStateDidChangeNotification时问题解决了。