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
How to show MPMoviePlayerController controls?
提问by npmrtsv
I have MPMoviePlayerController, and I want to show controls programmaticaly, like after user's tap, or simulate users tap.
我有 MPMoviePlayerController,我想以编程方式显示控件,比如在用户点击之后,或者模拟用户点击。
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 controlStyle
property to MPMovieControlStyleNone
initially, and then set it to MPMovieControlStyleFullscreen
one 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]
. 它运作良好,直到用户点击视频才会出现控件。