1

I am working on an app to show confidential data in UIWebview. All data cannot be stored on the device.

I am able to show contents and graphics by the NSData directly and I am now working on the video player. However I find it always require a local file path or a URL to play.

For example:

[Webview loadHTMLString:strVedio baseURL:[NSURL fileURLWithPath:path]];

May I ask whether there are anyway to play the video file from NSData directly? Thanks.

Forrest
  • 23
  • 5
  • Why don't you use remote url to play video? you somehow get the video - you firstly downloaded it from the remote to NSData, so just pass that url to loadHTMLString: baseURL: – Doro Mar 11 '16 at 09:22
  • It's because the video data is embedded and encrypted with numbers of items. I am not able to have a simple URL to tough this video file. Thanks for your reply! – Forrest Mar 11 '16 at 10:25
  • did you try http://stackoverflow.com/questions/10042225/how-to-play-a-nsdata-in-video-player ? – Doro Mar 11 '16 at 13:58

1 Answers1

-1

You can try to build an internal server working like a proxy, so that every request for the data will pass through your proxy server in localhost, as suggested here https://stackoverflow.com/a/20952163/7361753. With this, you will have an url for AVPlayer to play the video from NSData directly as the proxy streams data to it. I have tried this in my project of Swift 3 with this module https://github.com/httpswift/swifter , and it works pretty well , but if you want to work asynchronously such that the data have not been prepared yet on request, you may need to hack the module a little bit, so that the socket will not closed after giving out the first response.

Community
  • 1
  • 1