Reputation: 31
Using an AVAssetDownloadURLSession I am getting the following exception:
AVAssetDownloadTask does not support response property
I dont know why! Please help me fix this bug!!
Detail: *** Terminating app due to uncaught exception 'NSGenericException', reason: 'AVAssetDownloadTask does not support response property' *** First throw call stack: (0x1ac4f5344 0x1ac20acc0 0x1af88916c 0x104ecaed8 0x1af926904 0x1ac8d6004 0x1ac7d85a4 0x1ac8d8344 0x1ac7d827c 0x1ac8d8d70 0x1ac8d8830 0x107bf67c4 0x107be74d8 0x107bf5f64 0x1ac4708d4 0x1ac46b58c 0x1ac46abc8 0x1b684c5cc 0x1b061d744 0x104bb43b8 0x1ac2e7384) libc++abi.dylib: terminating with uncaught exception of type NSException
CODE:
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) )")
}
}
Upvotes: 2
Views: 628
Reputation: 31
Firebase SDK for Performence has includes FirebaseSwizzlingUtilities. This module handle some function. So, i removed it, everything work ok.
Upvotes: 1