gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 06:00:22 25 4
gpt4 key购买 nike

在按钮的 @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()
})

最佳答案

尝试改变UIwindowLevel,也许玩家等级上方会出现一个 View

         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()
})
}

关于ios - 使用 AVPlayer 黑屏(在模拟器和设备中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54734671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com