Http live streaming: Forcing MPMoviePlayerController to pack headers in the http requests

会有一股神秘感。 提交于 2019-12-11 04:46:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!