NSURLProtocol fails for video request

I'm having some issues with video requests handled through a special protocol scheme in a NSURLProtocol subclass. Every other resource (images/text) are getting handled correctly, however, when a video request is sent, I only get a call to 'canInitWithRequest' and no follow up. So, my video resource doesn't get resolved. Now, I've looked around and I found no definite solution for this. Some people use instead an embedded HTTP server, but that seems an overkill. Does anyone know if this is a bug or if not, why is this limitation, is there an workaround for it?

A similar issue: Custom NSURLProtocol class for WebView doesn't work when loading video in HTML5 document , but unfortunately without an answer.


@Meda, I was facing the similar issue. Here what I found and hope it is useful to you. I assume that you are using NSUrlProtocol because you want to intercept the video requests. I was using web view which makes request for video over HTTP. It goes to NSURLProtocol and makes the request. When it receives the data, webView loads the video rendering plugin (looking at the mime type in HTTP header). The plugin needs the data to come as Partial HTTP response (Response code 206). Further, the plugin does not use NSURLProtocol class but uses network layer below it. So requests that plugin makes, do not go thru NSURLProtocol. Considering this, there could be 2 problems in your case. 1. HTTP server you are using may not be supporting partial responses. 2. HTTP server is not reachable directly (Can you access the video from safari or any other
browser on your device?) You can verify both the cases by taking network trace. use tcpdump (available on Mac) to take network trace and see what is happening there.

链接地址: http://www.djcxy.com/p/5934.html

上一篇: NSURLProtocol和相对路径

下一篇: NSURLProtocol对视频请求失败