当用户尝试全屏播放时,MPMoviePlayerController 会停止并重置电影 [iOS]
我在邮件视图中嵌入了 MPMoviePlayerController。我可以播放/暂停电影并向前/向后寻找。但是,当我触摸“全屏按钮”时,影片停止,并且播放状态设置为 MPMoviePlaybackStateStopped... 是否应该全屏播放影片?
这是我的代码:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
player.shouldAutoplay = NO;
player.movieSourceType = MPMovieSourceTypeFile;
player.controlStyle = MPMovieControlStyleEmbedded;
player.allowsAirPlay = YES;
player.view.frame = CGRectMake(xPos, yPos, width, height);
[self.view addSubview:player.view];
I embedded a MPMoviePlayerController on my mail view. I can play/pause the movie and seek forward/backward. But when I touch the "fullscreen button" the movie stops and the playback state is set to MPMoviePlaybackStateStopped... Should the movie be played in full screen?
Here is my code:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
player.shouldAutoplay = NO;
player.movieSourceType = MPMovieSourceTypeFile;
player.controlStyle = MPMovieControlStyleEmbedded;
player.allowsAirPlay = YES;
player.view.frame = CGRectMake(xPos, yPos, width, height);
[self.view addSubview:player.view];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现了我的错误:当按下 MPMoviePlayerController 视图中的全屏切换按钮时,会调用方法“viewWillLayoutSubviews”。我永远无法想象这种行为......
我希望我的经验对其他开发人员有用。
I found my bug: when pressing the full screen toggle button in MPMoviePlayerController's view, the method "viewWillLayoutSubviews" is invoked. I could never imagine this behavior...
I hope my experience can be useful to other developers.
请记住,当 MPMoviePlayerController 全屏显示时,任何包含 ViewController 的 viewWillDisappear、viewDidDisappear 方法都会被调用。此外,当从全屏返回时,viewWillAppear 和 viewWillDisappear 也会被调用。
如果其中有任何影响视频播放行为的逻辑,它将被调用,除非您使用一些条件逻辑来查看视频是否仍在播放。
Remember that any containing ViewController will have its viewWillDisappear, viewDidDisappear methods invoked when the MPMoviePlayerController goes full screen. Also, viewWillAppear and viewWillDisappear get called when it comes back from full screen.
If you have any logic in there that affects video playback behavior, it'll get called unless you use some conditional logic to see if the video is still playing.