问题描述
我正在我的应用中播放本地视频。应用程序在模拟器上运行良好,但应用程序未在实际设备上显示视频,仅播放声音并且显示控件的其余部分为黑色。以下是我正在使用的代码:
@IBAction func play_video(_ sender: Any) {
guard let path = Bundle.main.path(forResource: "app_tutorial",ofType: "mp4") else {
return
}
let videoURL = NSURL(fileURLWithPath: path)
// Create an AVPlayer,passing it the local video url path
let player = AVPlayer(url: videoURL as URL)
let controller = AVPlayerViewController()
let audioSession = AVAudioSession.sharedInstance()
do
{
try audioSession.setCategory(AVAudioSessionCategoryPlayback,with: .duckOthers)
}
catch
{
print("AVAudioSession cannot be set")
}
controller.player = player
present(controller,animated: true) {
// player.play()
DispatchQueue.main.async {
player.play()
}
}
}
如果缺少什么,请指导我。 预先感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)