I'm trying to play a video file from a server, the file plays in the simulator, but it doesn't in the actual device. When the item's status changes (failed) the error message is:
Error Domain=AVFoundationErrorDomain Code=-11828 "Cannot Open" UserInfo=0x15542db0 {NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x156f49f0 "The operation couldn’t be completed. (OSStatus error -12847.)", NSLocalizedFailureReason=This media format is not supported.}
I've read in this question that the file should have either an extension or the server should reply with the correct mime type, however in this situation neither is possible.
I'd like to know if there's a way to modify the server response or provide the mime type programmatically, either with AVPlayer or MPMoviePlayerController. Thank you in advance.
I implemented a NSURLProtocol with a custom scheme to intercept the call and modify the response: