【问题标题】:Crash "AVAssetDownloadTask does not support response property"崩溃“AVAssetDownloadTask 不支持响应属性”
【发布时间】:2020-08-25 04:52:25
【问题描述】:

使用 AVAssetDownloadURLSession 我得到以下异常:

AVAssetDownloadTask 不支持响应属性

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

详情: *** 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“AVAssetDownloadTask 不支持响应属性” *** 首先抛出调用堆栈: (0x1ac4f5344 0x1ac20acc0 0x1af88916c 0x104ecaed8 0x1af926904 0x1ac8d6004 0x1ac7d85a4 0x1ac8d8344 0x1ac7d827c 0x1ac8d8d70 0x1ac8d8830 0x107bf67c4 0x107be74d8 0x107bf5f64 0x1ac4708d4 0x1ac46b58c 0x1ac46abc8 0x1b684c5cc 0x1b061d744 0x104bb43b8 0x1ac2e7384) libc++abi.dylib:以 NSException 类型的未捕获异常终止

代码:

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) )")
}

}

【问题讨论】:

    标签: ios swift xcode


    【解决方案1】:

    Firebase SDK for Performance 包含 FirebaseSwizzlingUtilities。这个模块处理一些功能。所以,我删除了它,一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 2016-06-07
      • 2012-02-24
      • 1970-01-01
      相关资源
      最近更新 更多