iPad MPMoviePlayerController - 禁用全屏
有没有办法禁用 MPMoviePlayerController 的全屏按钮?
Is there a way to disable the fullscreen button of the MPMoviePlayerController ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
刚刚做了:
Just did it:
根据您的需要,您还可以简单地禁用播放器视图上的所有用户交互。
Depending on your needs, you can also simply disable all user interactions on the player view.
您可以将 controlStyle 设置为全屏。这些控件有些不同,但它没有全屏按钮!
You can set controlStyle to Fullscreen. these controls are somewhat different, but it doesn't feature a Fullscreen button!
您可以隐藏播放控件并添加您自己的自定义控件,这将阻止默认按钮被渲染,
即
You could hide the playback controls and add your own custom ones, this will prevent the default buttons being rendered at all
I.e with
不幸的是,以上内容都不适合我,因此选择上面的内容我实现了以下内容(并且工作正常):
在初始化电影播放器的方法中添加此代码。
添加方法:
问题在于没有标签来标识您必须隐藏哪个视图。就我而言,我通过视图坐标来计算出来。
并添加选择器方法:
Unfortunately none of above worked for me properly, so picking the above I implemented the following (and worked fine):
Add this code in the method where you initialise the movie player.
Add the methods:
The problem relies that there is no tag to identify which view you have to hide. In my case I figure it out by the view coordinates.
And add the selector methods:
有一个作弊:
主要的问题是,您必须在
viewDidAppear:
或类似的位置执行此操作,因为 MoviePlayer 视图会在didMoveToWindow
或didMoveToSuperview< 内部的某个位置进行设置/code>,发生在
viewWillAppear:
之后。因此,您会看到全屏按钮的短暂闪烁。其他明显的问题包括: brittle 与 Apple 更改 512 标签值(尽管它在 3.2 - 4.2 中有效);当然,苹果不希望你这样做。认可的解决方案是将控件样式设置为 MPMovieControlStyleNone 并滚动您自己的传输控件,这需要更多工作。
There's a cheat:
The main catch is, you have to do it in
viewDidAppear:
or similar, because the MoviePlayer view sets itself up somewhere insidedidMoveToWindow
ordidMoveToSuperview
, which happen afterviewWillAppear:
. So you get a brief flash of the fullscreen button. Other obvious catches include: brittle vs. Apple changing that 512 tag value (although it works in 3.2 - 4.2); and of course Apple would rather you not do this.The endorsed solution is to set the control style to
MPMovieControlStyleNone
and roll your own transport controls, which is more work.不,没有办法。希望下次更新。
No, there is no way. Hopefully with the next update.
为了禁用切换到全屏模式,无论是表单按钮还是捏合手势,您可以使用以下命令:
in order to disable switch to full screen mode, either form button or pinch gesture, you can use this:
有线就是这样做的。对于以全屏启动的视频,它们具有标准的 MPMoviePlayerController 控件,但缺少全屏按钮。他们正在使用标准的内置按钮,因为他们突然有了 4.2 的 AirPlay 按钮。
Wired does this. For the videos that start in fullscreen, they have the standard MPMoviePlayerController controls, but are missing the fullscreen buttons. And they're using the standard built-in ones, since they suddenly got an AirPlay button with 4.2.
在这里删除捏缩放的简单块
希望它能帮助
我在 iOS6 上工作
Simple block to remove pinch zoom here
Hope it help
it work with me on iOS6
这适用于 iOS 7、iPhone 5s。
请注意,我只监听“DID”而不是“WILL”通知以及以动画方式运行它。我认为这很有效,因为它给了系统反应的时间。当我使用上面答案中提到的“WILL”和“DID”时,它导致黑屏,没有控件。发生转换时会出现轻微的故障,但我需要嵌入的播放/滑动按钮。
This worked on iOS 7, iPhone 5s.
Notice that I only listen for "DID" and not the "WILL" notification as well as running it animated. I think this works as it gives the system time to react. When I used the "WILL" and "DID" as noted in answers above it led to a black screen with no controls. There is a slight glitch that is visible when the transition occurs, but I need the play/scrub buttons from embedded.
全屏按钮和暂停按钮可以删除。
Fullscreen button along with pause button can be removed.
如果您想要做的唯一事情是禁用捏合以全屏显示(即保持交互启用以及您想要的任何控制样式),您可以使用以下命令:
If the only thing you want to do is disable pinch to go full screen (i.e. keep interaction enabled and whatever control style you want), you can use this:
这是 Javier Calatrava Llavería 第一个解决方案的 Swift 版本:
当用户点击 Play 时:
(VideoViewController 是我在其中拥有 MPMoviePlayerController 的视图控制器)
This is the Swift version of the first solution of Javier Calatrava Llavería:
And when the user taps on Play:
(VideoViewController is the view controller in which I have the MPMoviePlayerController)
我知道,这有点过时了,但无论如何。我在这个方向做了一些研究,看起来找到了答案。我不知道为什么它有效,但它确实有效。
// 电影结束后,释放控制器。
I know, it's a little outdated, but anyway. I did some research in that direction, and looks like a found an answer. I do not know, why it's working, but it is.
// When the movie is done, release the controller.
将具有透明背景的
UIView
或UIButton
放置在显示视频的视图顶部,以便用户无法点击包含视频的视图。Put a
UIView
orUIButton
with transparent background on top of the view that shows the video, so that the user won't be able to tap on the view that contains the video.