iOS 9 'Picture In Picture' 模式在 'Requires Fullscreen' 设置为 YES 时可用吗?

iOS 9 is 'Picture In Picture' mode available with 'Requires Fullscreen' set to YES?

我有一个需要全屏的应用程序,但想在用户打开视频播放模式控制器(我自己用 AVFoundation 编写的播放器)时使画中画功能可用。 我在设置中将 'app requires fullscreen' 标志设置为 YES。

当我的所有应用程序都需要全屏时,我可以使用画中画模式播放视频吗?

我创建了一个示例项目,发现是的,画中画功能不依赖于您的应用是否需要全屏。

也许这对那些和我有同样问题的人有帮助。

  1. 将基本 SDK 版本设置为最新 (9.0)
  2. 在项目设置中设置"App requires fullscreen"标志
  3. application:didFinishLaunchingWithOptions:

    中将AVAudioSession类别设置为AVAudioSessionCategoryPlayback
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    
  4. 刚刚创建了 AVPlayerViewController 并从我的根控制器中呈现它

    AVPlayerViewController *moviePlayerController = [[AVPlayerViewController alloc] init];
    AVPlayer *player = [AVPlayer playerWithURL:[NSURL URLWithString:@"http://127.0.0.1:12345/movie.mp4"]];
    moviePlayerController.player = player;
    [self presentViewController:moviePlayerController animated:YES completion:nil];
    
  5. 画中画按钮出现在播放控件的右下角,可以使用了!

P.S。如果问题和答案很明显或太简单并且没有人觉得有用,我可能会删除它。