在热点时全屏调整窗口大小时AVPlayer崩溃 [英] AVPlayer crash when resizing window during fullscreen while hotspotting

查看:809
本文介绍了在热点时全屏调整窗口大小时AVPlayer崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用可以观看各种视频的应用进行编码。我在按钮点击时全屏打开视频,用户可以使用播放控件来调整窗口大小。我遇到的问题是,当用户通过热点共享他的互联网时,应用程序顶部有一个蓝色条。此时调整窗口大小会导致AVKit框架崩溃(我相信)。使用Swift 2.3,Xcode 7.3.1。我的手机,iPhone 6s,使用iOS 10,我也在iOS 9 iPhone 6 Plus上尝试过,同样的问题。

I'm coding on an app where uses can watch a wide array of videos. I open the video in fullscreen on button tap and the user is able to use the playback controls to resize the window. The issue I'm having is that when the user is sharing his internet through hotspot there is a blue bar at the top of the app. When resizing the window at this point will cause a crash in the AVKit framework (I believe). Using Swift 2.3, Xcode 7.3.1. My phone, iPhone 6s, uses iOS 10 and I've also tried it on iOS 9 iPhone 6 Plus, same issue.

崩溃:

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<AVFullScreenPlaybackControlsViewController: 0x102933000> should have parent view controller:<AVPlayerViewController: 0x10212d800> but actual parent is:<AVFullScreenViewController: 0x10884d900>'

我的代码:

private let playerController = AVPlayerViewController()
private var player: AVPlayer!

private func playVideo(media: Media) {

        player = AVPlayer(URL: NSURL(string: media.url)!)
        playerController.player = player

        presentViewController(playerController, animated: true, completion: {
            self.playerController.player?.play()
            self.playerController.delegate = self
        })

    }

如果我不在手机上分享我的网络(因此没有蓝色条)然后它工作正常,没有任何问题。有人设法隐藏这个蓝色条,或遇到类似的问题吗?

If I don't share my internet on my phone (thus no blue bar) then it works fine, no issues whatsoever. Anyone managed to hide this blue bar, or experienced a similar issue?

推荐答案

我已修复此代码:

@interface YourAVPlayerViewController : AVPlayerViewController
@end

@implementation YourAVPlayerViewController

 - (BOOL)prefersStatusBarHidden {
        return YES;
 }

@end

这篇关于在热点时全屏调整窗口大小时AVPlayer崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆