现已弃用的旧“ MPMoviePlayerController”具有“ MPMoviePlayerWillEnterFullScreen”的委托。
浏览文档后,找不到与当前标准“ AVPlayerViewController”类似的东西。
https://developer.apple.com/documentation/avkit/avplayerviewcontrollerdelegate
基于播放器全屏切换时,如何为AVPlayerViewController实现委托?
谢谢。
答案 0 :(得分:0)
我不相信您提到过任何内置通知。您可以观察到对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发生变化,因此您需要在逻辑中加以考虑。