如何检测iPhone MPMoviePlayer控件何时出现/消失?

Mar*_*ith 5 iphone mpmovieplayercontroller mpmovieplayer

我正在尝试在MPMoviePlayerController视图(OS 2.x及更高版本)中的标准快退/播放/转发控件的左侧和右侧添加自定义按钮.我已经想出如何将它们添加到播放器窗口,但它们始终可见.有没有办法检测标准控件何时出现和消失?

cyb*_*cow 10

好的,得到它,像这样:

BOOL controlsVisible = NO;
for(id views in [[_moviePlayer view] subviews]){
 for(id subViews in [views subviews]){
   for (id controlView in [subViews subviews]){
     controlsVisible = ([controlView alpha] <= 0.0) ? (NO) : (YES);
   }
  }
}
NSLog(@"player controls are visible: %d", controlsVisible);
Run Code Online (Sandbox Code Playgroud)

其中_movePlayer是您的播放器的实例.在最深的循环中,如果控件被隐藏,MPFullScreenVideoOverlay视图实例将具有alpha == 0.0,如果显示控件,则为alpha 1.0.您可以添加观察者并根据需要触发.我知道它不优雅但它对我有用,因为Apple没有记录任何有关此任务的内容.

干杯......