vdugnist / DVAssetLoaderDelegate

Loader delegate for caching AVURLAsset
MIT License
104 stars 28 forks source link

iOS 13 #11

Open andriymobilemailinator opened 4 years ago

andriymobilemailinator commented 4 years ago

Hi,

I'd recommend to make a such or like this change:

inside the DVAssetLoaderDelegate.m

change

- (NSData *)subdataFromData:(NSData *)data
                 forRequest:(NSURLRequest *)request
                   response:(NSHTTPURLResponse *)response
             loadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest {
    NSString *requestRange = rangeFromRequest(request);
    NSString *responseRange = rangeFromResponse(response);

into


- (NSData *)subdataFromData:(NSData *)data
                 forRequest:(NSURLRequest *)request
                   response:(NSHTTPURLResponse *)response
             loadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest {
    NSString *requestRange = rangeFromRequest(request);
    if (response.statusCode == 200 && [requestRange isEqualToString:@"0-"]) {
        return data;
    }
    NSString *responseRange = rangeFromResponse(response);

because an urlAsset object(at iOS 13) requests a whole content immediately after the "bytes=0-1" request: "bytes=0-" as it requests a whole range there is no Content-Range in response from server and the received piece of data is not interpreted as valid.