我目前正在开发 HLS 播放器。在使用 Xcode 在模拟器上测试它时,我注意到它播放音频但不显示视频。
下面是代码片段
import UIKit
import AVKit
class ViewController: UIViewController {
let playerViewController = AVPlayerViewController()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func playVideo(_ sender: AnyObject) {
guard let url = URL(string: "https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8") else {
return
}
// Create an AVPlayer, passing it the HTTP Live Streaming URL.
let player = AVPlayer(url: url)
print("created player")
// Create a new AVPlayerViewController and pass it a reference to the player.
let controller = AVPlayerViewController()
controller.player = player
// Modally present the player and call the player's play() method when complete.
present(controller, animated: true) {
print("user started video")
player.play()
}
}
}
错误追踪
HALPlugIn.cpp:551 HALPlugIn::DeviceGetCurrentTime: got an error from the plug-in routine, Error: 1937010544 (stop)
我想要流畅的播放体验。
更新 xcode 版本后问题得到解决。谢谢