viePlayerController和MPVolumeView

viePlayerController和MPVolumeView

本文介绍了AirPlay支持,MPMoviePlayerController和MPVolumeView关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发支持视频播放的iPhone应用程序。我正在使用MPMoviePlayerController和自定义控件来播放视频。为此,我将MPMoviePlayerController的控件样式设置为MPMovieControlStyleNone。

I am developing an iPhone application that has support for video play. I am using MPMoviePlayerController with custom controls for playing the video. For this purpose I have set control style of MPMoviePlayerController to MPMovieControlStyleNone.

我想支持正在播放的视频的AirPlay功能。根据文档,我们必须将MPMoviePlayerController的'allowsAirPlay'属性设置为YES以启用AirPlay功能。如果我使用带有自定义控件的MPMoviePlayerController,如何在播放器UI上显示AirPlay按钮?

I would like to support AirPlay feature for the video being played. As per the documentation, we have to set the 'allowsAirPlay' property of MPMoviePlayerController to YES to enable AirPlay feature. How can I display the AirPlay button on my player UI if I am using MPMoviePlayerController with custom controls?

我尝试过以下操作:


  1. 实例化MPVolumeView

  2. 将MPVolumeView的showsRouteButton和showsVolumeSlider属性设置为NO以隐藏音量滑块和路线按钮

  3. 在我的自定义播放器上添加了MPVolumeView查看

我没有给对方提供MPVolumeView和MPMoviePlayerController的引用。
但是,如果MPMoviePlayerController的'allowsAirPlay'设置为YES,那么AirPlay按钮将显示在MPVolumeView上。 MPVolumeView和MPMoviePlayerController如何相关?请让我知道这两个独立创建的课程之间的联系。

I have not given the reference of MPVolumeView and MPMoviePlayerController to each other.But, if 'allowsAirPlay' of MPMoviePlayerController is set to YES then AirPlay button gets displayed on MPVolumeView. How are MPVolumeView and MPMoviePlayerController related? Please let me know the connection between these two classes which are created independently.

谢谢和问候,
Deepa

Thanks and Regards,Deepa

推荐答案

由于MPMoviePlayerController只允许您一次播放一个视频,因此MediaPlayer框架始终知道正在播放的视频。这就是MPVolumeView了解MPMoviePlayerController的方式。我没有正式的文档,但我认为它以这种方式融入框架。

Since the MPMoviePlayerController only allows you to play one video at a time, the MediaPlayer framework always knows the video that's playing. That's how MPVolumeView knows about the MPMoviePlayerController. I have no official docs, but I imagine it's baked into the framework this way.

因为可能有很多检查和平衡正在进行(并且他们喜欢一致的UI ),Apple仅允许您使用AirPlay按钮/ UI来使用此功能。但是,您可以将该按钮放在任何位置:

Since there are probably a lot of checks and balances going on (and they loves consistent UIs), Apple only allows you to use their AirPlay button/UI for tapping into this feature. You can, however, put that button wherever you want:

airplayButton = [[MPVolumeView alloc] init];
airplayButton.frame = CGRectMake(myX, myY, 40, 40);
[airplayButton setShowsVolumeSlider:NO];
[customPlayerControls.view addSubview:airplayButton];

我猜测宽度,高度为40,40,我确定它不正确,但是一旦我按下按钮就无所谓了。

I just guessed on the width,height being 40,40 and I'm sure it's not correct, but once I got the button in place it didn't matter.

这篇关于AirPlay支持,MPMoviePlayerController和MPVolumeView关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 01:56