I don't think AVFoundation provides access to all of those tags. However when I need to debug the streams, I use a custom NSURLProtocol to intercept all traffic. I think sometimes it's better to see the raw playlist and the HTTP response because AVPlayer does not give good error message(e.g. "The operation cannot be completed")
A good tutorial on NSURLProtocol can be found here: https://www.raywenderlich.com/59982/nsurlprotocol-tutorial
First let the url loading system know you can handle HLS request by calling [NSURLProtocol registerClass:/* your class */]
and override +(BOOL)canInitWithRequest:
+(BOOL)canInitWithRequest:(NSURLRequest *)request {
BOOL handled = [[NSURLProtocol propertyForKey:@"handled" inRequest:request] boolValue];
return [request.URL.pathExtension isEqualToString:@"m3u8"] && !handled;
}
Then override -(void)startLoading
in your custom URLProtocol
-(void)startLoading {
newRequest = [self.request mutableCopy];
[NSURLProtocol setProperty:@YES forKey:@"handled" inRequest:newRequest];
NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:newRequest
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
/* Inspect response body(playlist) and error */
NSString *responseBody = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
/* Return data and control to AVPlayer*/
[self.client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
[self.client URLProtocol:self didLoadData:data];
[self.client URLProtocolDidFinishLoading:self];
}];
[task resume];
}