本文介绍了如何让AVPlayerViewController以编程方式进入全屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式进入全屏模式,来自嵌入模式,但是使用已发布的API似乎无法实现这一点。

I'm trying to make a AVPlayerViewController go to full screen mode programmatically, coming from "embedded" mode, however this does not appear to be possible with the published API.

我缺少一种解决方法吗?我有兴趣获得与用户按下控件右下角的全屏按钮时相同的动画。

Is there a workaround that I'm missing? I'm interested in obtaining the same animation to the one that you get when the user presses the full screen button on the bottom right of the controls.

使用MPMoviePlayerController不是一个可行的选择,因为我可能一次播放多个视频。

Using MPMoviePlayerController is not a viable alternative since I might have more than one video playing at a time.

谢谢。

推荐答案

AVPlayerViewController是UIViewController的子类,因此它可以像任何其他视图控制器子类一样呈现。你能用 presentViewController:animated:completion

AVPlayerViewController is a subclass of UIViewController, so it is presentable like any other view controller subclass. Are you able to use presentViewController:animated:completion?

self.avPlayerController.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:self.avPlayerController animated:YES completion:nil];

然后在左上角显示完成按钮。

This then shows the "Done" button in the top left-hand corner.

这篇关于如何让AVPlayerViewController以编程方式进入全屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:16