使用AVPlayer的黑屏(在模拟器和设备中)

时间:2019-02-17 15:21:20

标签: ios swift xcode video avplayer

在按钮的@IBAction中使用此代码,视频播放器将打开,但仅显示黑屏。我不知道为什么。谢谢

Release

1 个答案:

答案 0 :(得分:0)

尝试更改 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()
                })
}