MPMoviePlayerController 启动时出现问题
我的 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];
大多数情况下,当视频未下载并且需要流式传输时,就会发生这种情况。
您知道为什么会发生这种情况吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我不听 MPMoviePlayerPlaybackStateDidChangeNotification 时问题已解决。
Problem solved while I not listen to MPMoviePlayerPlaybackStateDidChangeNotification.