【问题标题】:How to play url video using AVPlayerViewController如何使用 AVPlayerViewController 播放 url 视频
【发布时间】:2017-06-30 05:19:31
【问题描述】:

点击我的视频网址时,我得到的回应是:

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
}

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

【问题讨论】:

  • 你能在你的问题中发布你的一些代码吗?就像..你如何尝试播放你的目标网址?

标签: swift3 avplayer avplayerviewcontroller avplayeritem tvos10


【解决方案1】:

使用以下代码播放 URL 视频。这对你有用。

如果是视频 URL,则为“message?.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()
        })         

    }

谢谢!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-13
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多