首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到HLS下载

找不到HLS下载
EN

Stack Overflow用户
提问于 2018-07-09 16:01:22
回答 1查看 404关注 0票数 0

我尝试过以下几种方法:

代码语言:javascript
复制
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()
}

并实现了

代码语言:javascript
复制
func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
    print("didFinishDownloadingTo \(location.relativePath)")
    playOfflineAsset()
}

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

还添加了didCompleteWithError委派,但没有成功。我的类符合AVAssetDownloadDelegate

EN

回答 1

Stack Overflow用户

发布于 2018-08-23 14:12:29

AVAssetDownloadURLSession总是与真实的设备only..So一起工作,在你的情况下,它似乎你是在模拟器上尝试过的。

请使用Real device

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51240658

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档