NSURLProtocol fails for video request
Asked Answered
D

1

6

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.

Dannielledannon answered 24/2, 2014 at 18:17 Comment(5)
Add your code to questionInkle
Well, is just the standard protocol implementation, startLoading never gets called and I'm sure I register the protocol correctly. More than that, this is an known issue, so I really doubt my code has anything to do with it. I'm just trying to find a workaround to a known issue, adding the standard protocol implementation above, would help no one.Dannielledannon
"More than that, this is an known issue" I'm not certain which issue you're referring to, but if you already know that it doesn't work, what is your question? Or is this a duplicate of others' questions? If it is a "known issue," you should at least reference your existing research. Others indicate successful use of NSURLProtocol with video (aerych.com/blog/2012/01/08/…), so elaboration of your specific issue and how it differs are required.Eckel
Well, I know it's an issue (the fact that NSURLProtocol fails to handle video requests), not its solution @RobNapier. I've added a similar question as an edit. I don't consider this a duplicate, although the problem is pretty much the same, new versions of iOS have came out since then and I'm looking for a workaround or an explanation on why there is such limitation. Probably Apple's dev list are a better place to look for an answer, however, I though I should try here first.Dannielledannon
@RobNapier and yes (thanks for the link), it seems that other got it working, I wonder what's the difference...Dannielledannon
J
1

@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.

Jeffcott answered 4/4, 2014 at 11:1 Comment(1)
How do you suggest sending or getting the video data as a Partial HTTP response?Thorrlow

© 2022 - 2024 — McMap. All rights reserved.