What is the recommended way for handling error in AVAssetResourceLoaderDelegate? specifically network requests in shouldWaitForLoadingOfRequestedResource
/ shouldWaitForRenewalOfRequestedResource
?
However, there is no way for my app to know something went wrong until I start playing the video. I tried loadingRequest.finishLoading(with: err)
and return false
in the shouldWaitForLoadingOfRequestedResource
delegate call, but nothing was reported until the download finishes and the user starts playing the video.
the code goes like this..
let urlAsset = AVURLAsset(url: url)
asset?.resourceLoader.preloadsEligibleContentKeys = true
asset?.resourceLoader.setDelegate(self.fairPlayAssetLoaderDelegate, queue: DispatchQueue.global(qos: .default)) // fairPlayAssetLoaderDelegate is an object that implements AVAssetResourceLoaderDelegate
// send urlAsset to AVAssetDownloadURLSession.makeAssetDownloadTask
after setting preloadsEligibleContentKeys = true
, it seems like shouldWaitForLoadingOfRequestedResource
is called right away after setting the resource loader delegate in AVURLAsset. but there is no way to tell the resource loader has successfully got all the information it wants.
I tried using loadValuesAsynchronously
on AVURLAsset, but that's a no go either.
AVAssetDownloadURLSession doesn't always report the error either..
Thanks in advance.