Video streaming in MPMoviePlayerController embedded in UIWebView

I want to know that how networking streaming is performed in MPMoviePlayerController embedded in UIWebView in iOS. Is it performed using sockets or any other approach?

Firstly please understand my problem, I am playing youtube videos in UIWebView. When the video is loaded and start to play, MPMoviePlayerController (or something like that) is instantiated automatically. Now the thing is I want to pass all the urls through my proxy server along with some private message. I am using the following approach:

APPROACH 1

Create my own Custom NSURLProtocol Class and intercept every request and then open a socket, write my private message and then write GET/POST message and pass the response to webview. Everything's working fine. But when video start playing we did not get url requests so Its difficult to trace the url is passing through my proxy.

I have read in SO that MPMoviePlayerController didnot conform to NSURLProtocol, so we cannot intercept Requests flow through Video Controller. Here is the link:

How to play movie with a URL using a custom NSURLProtocol?

APPROACH 2

I override connect(), write() and read() methods and then print logs to find if the video data is flowing through read() and write() methods. But Still I am not getting the desired results. My all other network requests pass through these overriden methods, but only VideoData is not showing, Which means that MPMoviePlayerController not using sockets and read, write methods. Or Webview start a another process internally to instantiate Player.

How can I assure that MPMoviePlayerController did not creating a new process internally.

And if any one has a idea how to achieve this, plz share. Any help is appreciated. I am stuck into this.


You can do that by implement a local server. Instead of playing directly network stream, let it go through your local server and redirect it. In that way, you can use your own custom NSURLProtocol as well. I am also implementing a caching protocol for HLS stream using this approach. You can try it here .See also CocoaHTTPServer

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

上一篇: 如何通过继承NSURLProtocol来成功处理sftp://协议?

下一篇: 嵌入在UIWebView中的MPMoviePlayerController中的视频流