xcode 如何显示 MPMoviePlayerController 控件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12087086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:18:26  来源:igfitidea点击:

How to show MPMoviePlayerController controls?

objective-ciosxcodempmovieplayercontroller

提问by npmrtsv

I have MPMoviePlayerController, and I want to show controls programmaticaly, like after user's tap, or simulate users tap.

我有 MPMoviePlayerController,我想以编程方式显示控件,比如在用户点击之后,或者模拟用户点击。

http://i.stack.imgur.com/KYMmG.jpg (Sorry, I don't have enough reputation, to post images).

http://i.stack.imgur.com/KYMmG.jpg(抱歉,我没有足够的声誉,无法发布图片)。

How can I do this? Thanks.

我怎样才能做到这一点?谢谢。

回答by Vimal Venugopalan

creating the MPMoviePlayerController object in the following way would give you an interface for video controls

以下列方式创建 MPMoviePlayerController 对象将为您提供视频控件的界面

yourMoviePlayerController = [MPMoviePlayerController new];     
yourMoviePlayerController.controlStyle=MPMovieControlStyleEmbedded;
[yourMoviePlayerController setContentURL:[NSURL fileURLWithPath:videoPath]];
yourMoviePlayerController.backgroundView.hidden = YES;

[yourMoviePlayerController setScalingMode:MPMovieScalingModeAspectFit];
yourMoviePlayerController.shouldAutoplay=YES;
yourMoviePlayerController.movieSourceType = MPMovieSourceTypeFile;

回答by Gonzo Oin

Someone already answer to that question herei think

我想这里已经有人回答了这个问题

Set controlStyleproperty to MPMovieControlStyleNoneinitially, and then set it to MPMovieControlStyleFullscreenone second later using a [performSelector:withObject:afterDelay:1]. It works well, controls do not appear until user taps on video.

controlStyle属性设置为MPMovieControlStyleNone初始,然后MPMovieControlStyleFullscreen使用[performSelector:withObject:afterDelay:1]. 它运作良好,直到用户点击视频才会出现控件。