【问题标题】:Can't figure out HLS download无法弄清楚 HLS 下载
【发布时间】:2018-07-09 08:01:22
【问题描述】:

我尝试了以下方法:

func setupAssetDownload() {
    // Create new background session configuration.
    let configuration = URLSessionConfiguration.background(withIdentifier: "123124123152")

    // Create a new AVAssetDownloadURLSession with background configuration, delegate, and queue
    let downloadSession = AVAssetDownloadURLSession(configuration: configuration,
                                                assetDownloadDelegate: self,
                                                delegateQueue: OperationQueue.main)

    let url = URL(string: "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8")// HLS Asset URL
    let asset = AVURLAsset(url: url!)

    // Create new AVAssetDownloadTask for the desired asset
    let downloadTask = downloadSession.makeAssetDownloadTask(asset: asset,
                                                             assetTitle: "assetTitle",
                                                             assetArtworkData: nil,
                                                             options: nil)
    // Start task and begin download
    print(downloadTask.debugDescription)
    downloadTask?.resume()
}

并实施

func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
    print("didFinishDownloadingTo \(location.relativePath)")
    playOfflineAsset()
}

但委托方法 didFinishDownloadingTo 从未被调用。

还添加了didCompleteWithError 委托,但没有成功。 我的班级符合AVAssetDownloadDelegate

【问题讨论】:

标签: swift swift4 http-live-streaming


【解决方案1】:

AVAssetDownloadURLSession 总是只在真实设备上工作。所以在你的情况下,你好像在模拟器上试过。

请使用真机

【讨论】:

    猜你喜欢
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多