
一切都在iOS 10中运行.而且在iOS 11中它正确播放视频.
但是在iOS 11中,当我开始向任何方向滑动时,它会立即使视频变黑并且还会使音频静音.它还会在底部的时间轴旁边显示一个加载指示器.
它也忽略了allowsPictureInPicturePlayback属性,因此它不会在iOS 11上显示PIP-button.
这是我使用的代码:
avPlayerController = AVPlayerVIEwController()avPlayerController?.showsPlaybackControls = trueavPlayerController?.allowsPictureInPicturePlayback = trueavPlayerController?.player = AVPlayer(url: vIDeoUrl as URL)avPlayerController?.player?.play() self.present(self.avPlayerController!,animated: true,completion: nil) avPlayerController?.player?.actionAtItemEnd = AVPlayerActionAtItemEnd.noneNotificationCenter.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)好的,我发现了错误:
要在按“完成”时关闭Airplay视频播放,我使用了以下代码:
overrIDe func vIEwWillAppear(_ animated: Bool) { super.vIEwWillAppear(animated) if avPlayerController?.isBeingdismissed ?? false { avPlayerController?.player = nil }} 但是对于iOS 11,Apple添加了一项功能,通过轻扫手势关闭视频播放器.因此,当我滑动时,会调用vIEwWillAppear函数.将此代码放在vIEwDIDAppear中修复此问题并保留AirPlay-Fix.
总结以上是内存溢出为你收集整理的swift – 在iOS 11上滑动时AVPlayerViewController黑屏全部内容,希望文章能够帮你解决swift – 在iOS 11上滑动时AVPlayerViewController黑屏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)