如何使用AvplayerviewController播放URL视频



击中我的视频URL时,我得到的响应是:

Error Domain = AVFoundationErrorDomain 
Code = -11853 "Playlist not received, See -[AVPlayerItem errorLog] for 2 events"
UserInfo = {
    NSUnderlyingError = 0x600000251670 
        {
        Error Domain = CoreMediaErrorDomain 
        Code=-12884 "Playlist File not received" 
        UserInfo = {NSDescription = Playlist File not received}
        }, 
    NSLocalizedFailureReason = This data is damaged, incomplete, or incompatible.,
    NSDebugDescription = Playlist not received, 
    See -[AVPlayerItem errorLog] for 2 events, 
    NSLocalizedDescription = Cannot Parse
}

我在过去的两天里被困在过去的两天中,无法找到出路。

使用以下代码播放URL视频。这将为您工作。

如果视频URL,则"消息?.link"。handleplay((函数在单击按钮上播放视频。

var playerLayer: AVPlayerLayer?
var player: AVPlayer?
func handlePlay() {
    if let videoUrlString = message?.link {                      
        let videoURL = URL(string: videoUrlString)
        self.player = AVPlayer(url: videoURL!)
        let playerViewController = AVPlayerViewController()
        playerViewController.player = ChatMessageCell.player
        nav.present(playerViewController, animated: true, completion: {
            self.player?.play()
        })         
    }

谢谢!

相关内容

  • 没有找到相关文章

最新更新