[HLS流- SWIFT播放器] HAL插件-设备获取当前时间问题

eh57zj3b  于 2023-11-16  发布在  Swift
关注(0)|答案(1)|浏览(144)

我目前正在开发一个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()
        }
    }
}

字符串
误差轨迹
第一个月
我想要流畅的播放体验。

yfjy0ee7

yfjy0ee71#

更新xcode版本后,问题得到解决。谢谢

相关问题