Http 直播:强制 MPMoviePlayerController 在 http 请求中打包标头
我正在使用 Http Live Streaming 将视频从服务器流式传输到 iPhone。我需要在手机发送到服务器的 http 数据包中设置某些标头。
对于常规数据包,以下代码就足够了:
NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url]
autorelease];
[request setValue:VALUE forHTTPHeaderField:@"Field You Want To Set"];
不幸的是,我没有找到类似的 MPMoviePlayerController
API。换句话说,如何强制 MPMoviePlayerController 在用于与服务器通信的 http 数据包中设置某些标头?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为设置 cookie 可能会解决您的问题。请查看 NSHTTPCookie 和 NSHTTPCookieStorage 的文档。
I think setting a cookie might solve your problem. Please look into the documentation for NSHTTPCookie and NSHTTPCookieStorage.
我认为除了使用 NSHTTPCookieStorage 让客户端将基于 cookie 的标头发送到服务器之外,您不会找到其他解决方案。
I don't think you'll find a solution other than using NSHTTPCookieStorage to have the client send cookie based headers to the server.
最近,我也遇到了这个问题,从堆栈溢出中发现解决方案是使用 NSURLProtocol。尽管如此,弄清楚如何做到这一点还是很痛苦,所以我想通过分享编码解决方案可以节省人们一些时间:https: //stackoverflow.com/a/23261001/3547099
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