使用 AVPlayer 的黑屏(在模拟器和设备中)
Posted
技术标签:
【中文标题】使用 AVPlayer 的黑屏(在模拟器和设备中)【英文标题】:Black screen using AVPlayer (both in simulator and in device) 【发布时间】:2019-02-17 15:21:19 【问题描述】:在按钮的@IBAction 中使用此代码会打开视频播放器,但它只显示黑屏。我不知道为什么。谢谢
if let path = Bundle.main.path(forResource: "Timelapse Stabilizzata", ofType: "mov")
let video = AVPlayer(url: URL(fileURLWithPath: path))
let videoPlayer = AVPlayerViewController()
videoPlayer.player = video
present(videoPlayer, animated: true, completion:
video.play()
)
【问题讨论】:
控制台是否出现任何错误? 【参考方案1】:尝试改变UIwindowLevel,也许玩家层级上方出现了一个视图
if let path = Bundle.main.path(forResource: "Timelapse Stabilizzata", ofType: "mov")
let video = AVPlayer(url: URL(fileURLWithPath: path))
let videoPlayer = AVPlayerViewController()
videoPlayer.view.window?.windowLevel = 0
videoPlayer.player = video
present(videoPlayer, animated: true, completion:
video.play()
)
【讨论】:
它不会改变任何东西:(以上是关于使用 AVPlayer 的黑屏(在模拟器和设备中)的主要内容,如果未能解决你的问题,请参考以下文章