I'm trying to use the resourceLoader
of an AVAsset
to progressively supply media data. Unable to because the delegate asks for the full content requestsAllDataToEndOfResource = true
.
class ResourceLoader: NSObject, AVAssetResourceLoaderDelegate {
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
if let ci = loadingRequest.contentInformationRequest {
ci.contentType = // public.mpeg-4
ci.contentLength = // GBs
ci.isEntireLengthAvailableOnDemand = false
ci.isByteRangeAccessSupported = true
}
if let dr = loadingRequest.dataRequest {
if dr.requestedLength > 200_000_000 {
// memory pressure
// dr.requestsAllDataToEndOfResource is true
}
}
return true
}
}
Also tried using a fragmented MP4 created using AVAssetWriter. But didn't work. Please let me know if it's possible for the AVAssetResourceLoader
to not ask for the full content?