繁体   English   中英

无法检测到全屏AVPlayerViewController过渡

[英]Can't detect fullscreen AVPlayerViewController transitions

现在已弃用的旧“ MPMoviePlayerController”具有“ MPMoviePlayerWillEnterFullScreen”的委托。

https://developer.apple.com/documentation/foundation/nsnotification/name/1620898-mpmovieplayerwillenterfullscreen

浏览文档后,找不到与当前标准“ AVPlayerViewController”相似的内容。

https://developer.apple.com/documentation/avkit/avplayerviewcontrollerdelegate

基于播放器全屏切换时,如何为AVPlayerViewController实现委托?

谢谢。

我不相信您提到过任何内置通知。 您可以观察到对AVPlayerViewController的videoBounds的更改:

    [self.playerViewController addObserver:self forKeyPath:@"videoBounds" options:0 context:NULL];

一旦观察到,然后使用您自己的逻辑来确定是将其切换到全屏显示还是其他范围更改:

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if (object == self.playerViewController && [keyPath isEqualToString:@"videoBounds"]) {
        // check your playerViewController videoBounds here compared to what they were previously
        // they could change outside of toggleFullScreen (rotation for example)
    }
}

正如我在此处的评论所指出的那样,旋转很可能也会导致videoBounds发生变化,因此您需要在逻辑中加以考虑。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM