Posts

Post not yet marked as solved
2 Replies
2.0k Views
I have been trying to multiple HLS audio files together. The files are encrypted with a key. I| need to fetch the key and store it locally for offline use. When I download a small number (2 or 3 files) of files simultaneously it works fine, but if I start downloading 10-15 files simultaneously most of them fails with the error message-Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-17377), NSLocalizedDescription=The operation could not be completed}I am getting error message from NSURLErrorDomain as well but they are rare.Below is my download function -class AudioDownloader { var productKey: String var downloadUrl: URL var downloadSession: AVAssetDownloadURLSession? var fakeDownloadUrl: URL? var downloadTask: AVAssetDownloadTask?func downloadAudio() { if downloadSession == nil { let configuration = URLSessionConfiguration.background(withIdentifier: self.productKey) downloadSession = AVAssetDownloadURLSession(configuration: configuration, assetDownloadDelegate: self, delegateQueue: OperationQueue.main) configuration.shouldUseExtendedBackgroundIdleMode = true configuration.httpShouldSetCookies = true configuration.httpShouldUsePipelining = false configuration.allowsCellularAccess = true configuration.isDiscretionary = true } self.fakeDownloadUrl = self.convertToScheme(url: self.downloadUrl, scheme: "fakehttp") let asset = AVURLAsset(url: self.fakeDownloadUrl!) let loader = asset.resourceLoader loader.setDelegate(self, queue: DispatchQueue(label: "dispatch2")) self.downloadTask = downloadSession?.makeAssetDownloadTask(asset: asset, assetTitle: "assetTitle \(self.productKey)", assetArtworkData: nil, options: nil)! self.downloadTask?.taskDescription = self.productKey self.downloadTask?.resume()}}The link of the approach which I am using to fetch the key for offline use is below -https://stackoverflow.com/questions/45670774/playing-offline-hls-with-aes-128-encryption-iosAny help would be appreciated.
Posted Last updated
.