简体   繁体   English

使用SDK在iPhone上下载视频

[英]Downloading Video on iPhone using SDK

I would like to develop such iphone application that provides functionality to download viedo. 我想开发提供下载viedo功能的iphone应用程序。 i am doing some as below 我正在做一些如下

1) Loading HTML content on web view 2) The loaded html content contains the video link (ie http://test.com/test.mp4 ") 3) When i click on that it will play the video in native player. 4) but i would like to prevent this thing and start downloading video from that URL for example, if i click on link it should not open native video player, it should start downloading from that url and store somewhere on iphone (ie document directory) 1)在Web视图上加载HTML内容2)加载的html内容包含视频链接(即http://test.com/test.mp4“)3 )当我单击该按钮时,它将在本机播放器中播放视频。4 ),但我想防止这种情况并开始从该URL下载视频,例如,如果我单击链接,则不应打开本机视频播放器,应从该URL开始下载并存储在iphone上的某个位置(即文档目录)

is there any solution for same? 有什么解决办法吗?

Thanks Vivek 谢谢Vivek

You should use UIWebViewDelegate s webView:shouldStartLoadWithRequest:navigationType: method to decide whether or not to load a URL. 您应该使用UIWebViewDelegatewebView:shouldStartLoadWithRequest:navigationType:方法来决定是否加载URL。

You can check the request, and perform some logic, for instance, checking if the URL's suffix is 'mp4' and if so, do something other than load the request in the webview. 您可以检查请求,并执行一些逻辑,例如,检查URL的后缀是否为“ mp4”,如果是,则执行除将请求加载到Web视图之外的其他操作。

You can intercept the mp4 urls, and then hand them off to another method in your controller that will kick off an NSURLRequest to download the video data. 您可以截获mp4网址,然后将其交给控制器中的另一个方法,该方法将启动NSURLRequest以下载视频数据。

Once you have the video data, you can write it to the documents directory. 获得视频数据后,可以将其写入documents目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM