【问题标题】:Black screen using AVPlayer (both in simulator and in device)使用 AVPlayer 的黑屏(在模拟器和设备中)
【发布时间】: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()
        })

【问题讨论】:

  • 控制台是否出现任何错误?

标签: ios swift xcode video avplayer


【解决方案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()
                })
}

【讨论】:

  • 它不会改变任何东西:(
猜你喜欢
  • 2018-08-29
  • 1970-01-01
  • 2012-04-18
  • 2017-03-09
  • 1970-01-01
  • 2020-06-15
  • 2014-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多