MPMoviePlayerController No Longer Uses NSURLProtocol

Originator:hodgesmr1
Number:rdar://18797093 Date Originated:2014-10-28
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification:Bug Reproducible:Always
 
Summary:
I have created an NSURLProtocol subclass so that I can dynamically add headers to my NSURLRequests. This is particularly useful when loading streaming content via URL with MPMoviePlayerController. We add custom headers to access the streaming content, and since MPMoviePlayerController does not allow an init with NSURLRequest (only NSURL) the headers are added by the NSURLProtocol subclass. In previous version of iOS (7.x) this worked seamlessly. In iOS 8, the NSURLProtocol's `canInitWithRequest` method is never hit when the MPMoviePlayerController begins playback.

Steps to Reproduce:
1. Register a custom NSURLProtocol subclass, eg customScheme:
2. Build a URL that conforms to that subclass, e.g. customScheme://example.com/variant.m3u8
3. Pass that URL into an MPMoviePlayerController via initWithContentURL

Expected Results:
The NSURLProtocol subclass's canInitWithRequest method should hit, as well as its startLoading and stopLoading methods

Actual Results:
This method is not hit when a url is loaded via the MPMoviePlayerController. It is hit, however, from other http requests in the app.

Version:
iOS 8.1

Notes:
I tested this on iOS 7.x devices, and the NSURLProtocol is behaving as expected with MPMoviePlayerControllers

Configuration:
iPhone 5s, WiFi

Comments

I'm having same problem. Want to handle loading of HLS encryption keys using NSURLProtocol but it never gets called using AVPlayer.

Apples docs and WWDC videos tell us this is how to do it, but the player won't let that happen. Confused!

By coolplasma at Nov. 1, 2015, 2:30 a.m. (reply...)

AVPlayer does not work with NSURLProtocol too. Even more confusing, it does work on simulator!


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!