首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Crash "AVAssetDownloadTask不支持响应属性“

Crash "AVAssetDownloadTask不支持响应属性“
EN

Stack Overflow用户
提问于 2020-08-25 12:52:25
回答 1查看 176关注 0票数 1

使用AVAssetDownloadURLSession时,我得到了以下异常:

AVAssetDownloadTask不支持响应属性

我不知道为什么!请帮我修复这个bug!!

详细信息:*因未捕获异常'NSGenericException‘终止app,原因:'AVAssetDownloadTask不支持响应属性’*第一次抛出调用堆栈:(0x1ac4f5344 0x1ac4f5344 0x1ac20acc0 0x1af88916c 0x104ecaed8 0x1af926904 0x1ac8d6004 0x1ac7d85a4 0x1ac8d8344 0x1ac7d827c 0x1ac8d8d7d70 0x1ac8d8830 0x107bf67c4 0x107be74d8 0x107bf5f64 0x1ac4708d4 0x1acb58c 0x1ac46abc8 0x1b684c5c5cc 0x1b0661d744 0x1ac8b43b8 0x1ac2e7384):终止,NSException异常类型为

代码:

代码语言:javascript
复制
class ADownloader: NSObject,AVAssetDownloadDelegate {
func setupAssetDownload() {
    // Create new background session configuration.
    let configuration = URLSessionConfiguration.background(withIdentifier: "AssetID")
    
    // Create a new AVAssetDownloadURLSession with background configuration, delegate, and queue
    let downloadSession = AVAssetDownloadURLSession(configuration: configuration,
                                                    assetDownloadDelegate: self,
                                                    delegateQueue: OperationQueue.main)
    
    let url = URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")
    // let url = URL(string: "https://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8")
    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
    downloadTask?.resume()
}

//MARK: Delegates
public func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL){
    print("DownloadedLocation:\(location.absoluteString)")
}

public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
    print("Error")
    print(error.debugDescription)
}

public func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) {
    print(error.debugDescription)
    print("Error")
}

public func urlSession(_ session: URLSession, taskIsWaitingForConnectivity task: URLSessionTask) {
    print("Waiting")
}

public func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
    print("Finihs collecting metrics:")
}
func urlSession(_ session: URLSession,
                assetDownloadTask: AVAssetDownloadTask,
                didLoad timeRange: CMTimeRange,
                totalTimeRangesLoaded loadedTimeRanges: [NSValue],
                timeRangeExpectedToLoad: CMTimeRange) {
  
    var downloadedContentDuration = 0.0

    loadedTimeRanges.forEach { (value) in
        let timeRange = value.timeRangeValue
        downloadedContentDuration += timeRange.duration.seconds
    }

    print("Progress \(CGFloat(downloadedContentDuration / timeRangeExpectedToLoad.duration.seconds) )")
}

}

EN

回答 1

Stack Overflow用户

发布于 2020-08-25 15:49:40

Firebase SDK for Performence包含FirebaseSwizzlingUtilities。这个模块处理一些功能。所以,我把它移走了,一切正常。

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

https://stackoverflow.com/questions/63572239

复制
相关文章

相似问题

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