我正在使用
当屏幕变黑时,我在控制台中看到以下内容:
AVPlayerViewController
播放iPad应用程序上的视频文件(H.264,AAC,MP4容器)。在iOS 10中一切正常。在iOS 11中,当我开始向任何方向滑动时,它会立即使视频变黑并静音。它还在底部时间轴旁边显示了一个加载指示器。此外,它忽略了allowsPictureInPicturePlayback
属性,因此在iOS 11上不会显示PIP按钮。这是我使用的代码:avPlayerController = AVPlayerViewController()
avPlayerController?.showsPlaybackControls = true
avPlayerController?.allowsPictureInPicturePlayback = true
avPlayerController?.player = AVPlayer(url: videoUrl as URL)
avPlayerController?.player?.play()
self.present(self.avPlayerController!, animated: true, completion: nil)
avPlayerController?.player?.actionAtItemEnd = AVPlayerActionAtItemEnd.none
NotificationCenter.default.addObserver(self, selector: #selector(onVideoCompleted), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.avPlayerController!.player?.currentItem)
并且这个函数用于在视频结束时关闭视频播放器:
func onVideoCompleted(notification:Notification) {
self.avPlayerController?.player = nil
self.avPlayerController?.dismiss(animated: true, completion: nil)
}
当屏幕变黑时,我在控制台中看到以下内容:
AVOutputDeviceDiscoverySession (FigRouteDiscoverer)
>>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl
outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery
mode to DiscoveryMode_Presence (client: MyAppName)
将设备发现模式设置为DiscoveryMode_None(客户端:APPNAME)[播放]❗️无法排队任何项。
之后,即使我尝试通过将播放器设置为空来解决上述问题,AVPLayer视频也无法播放并且被冻结。这只会在设备通过AirPlay连接时发生。 - Kushal AshokviewWillAppear
方法中终止了视频播放。 - Dan Morrow