使用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异常类型为
代码:
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) )")
}}
发布于 2020-08-25 15:49:40
Firebase SDK for Performence包含FirebaseSwizzlingUtilities。这个模块处理一些功能。所以,我把它移走了,一切正常。
https://stackoverflow.com/questions/63572239
复制相似问题