问题
I am streaming video from a server to iPhone using Http Live Streaming. I need to set certain headers in the http packets that the phone sends to the server.
For regular packets, the following code would suffice:
NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url]
autorelease];
[request setValue:VALUE forHTTPHeaderField:@"Field You Want To Set"];
Unfortunately, I did not find a similar API for MPMoviePlayerController
. In other words, how do I force MPMoviePlayerController
to set certain headers in the http packets that it uses to communicate to the server?
回答1:
I think setting a cookie might solve your problem. Please look into the documentation for NSHTTPCookie and NSHTTPCookieStorage.
回答2:
I don't think you'll find a solution other than using NSHTTPCookieStorage to have the client send cookie based headers to the server.
回答3:
Recently, I had this problem too, and found from stack overflow that the solution is to use NSURLProtocol. Still, it was painful figuring out how to do it, so I thought I'd save people some time by sharing the coded solution: https://stackoverflow.com/a/23261001/3547099
来源:https://stackoverflow.com/questions/6763325/http-live-streaming-forcing-mpmovieplayercontroller-to-pack-headers-in-the-http