I am currently displaying a video in an iOS app using MPMoviePlayerController. Files are transferred from our server server, which requires authentication. This is an authenticated key based on the key in the authorization HTTP header.
It worked great with individual video files. Now we tried to implement adaptive HLS streaming, and we ran into it. Currently, I use my own subclass NSURLProtocolto catch requests made to our server server and enter the appropriate authorization header. For HLS, it just doesn't work.
When we looked at the server logs, we clearly saw that the first request to the m3u8 file worked fine. Then all subsequent calls (other m3u8 and ts files as well) are forbidden 403. It seems that it is MPMoviePlayerControllernot used NSURLProtocolfor other files. (side note: it works on the simulator, but not on the physical device, which allows me to think that both of them are not implemented equally).
Create an instance of MPMoviePlayerController
self.videoController = [[MPMoviePlayerController alloc] initWithContentURL:video.videoURL];
URL protocol interception
+ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
NSMutableURLRequest *newRequest = request.mutableCopy;
[newRequest setValue:@"HIDDEN" forHTTPHeaderField:@"Authorization"];
return newRequest;
}
Any ideas, suggestions, work around?
source
share