当用户尝试全屏播放时,MPMoviePlayerController 会停止并重置电影 [iOS]

发布于 2024-12-10 18:24:55 字数 525 浏览 0 评论 0原文

我在邮件视图中嵌入了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

肥爪爪 2024-12-17 18:24:55

我发现了我的错误:当按下 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.

老街孤人 2024-12-17 18:24:55

请记住,当 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文