我想使用网络视图下载视频,但我没有得到如何下载它? 我的视频链接是here
我正在使用的播放视频的示例代码是
-(void)embedYouTubeInWebView:(NSString*)url theWebView:(UIWebView *)aWebView {
NSString* html = [NSString stringWithFormat:@"%@", url];
[aWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:html]]];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self embedYouTubeInWebView:@"http://player.vimeo.com/video/32983838" theWebView:myWebView];
// Do any additional setup after loading the view, typically from a nib.
}
有人可以帮我下载这个视频吗?
答案 0 :(得分:5)
要下载文件,我使用以下代码。希望它也适合你。
- (IBAction)getFileFromFtpServer:(UIView *)sender
{
NSString *stringURL = @"http://player.vimeo.com/video/32983838";
NSURL *url = [NSURL URLWithString:stringURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"filename.mpeg4"];
[urlData writeToFile:filePath atomically:YES];
}
}
答案 1 :(得分:2)
Try this here your video is playing..
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 380)];
webView.delegate=self;
[webView setOpaque:NO];
webView.backgroundColor=[UIColor clearColor];
CGRect screen = [[UIScreen mainScreen] bounds];
CGFloat width = CGRectGetWidth(screen);
CGFloat height = CGRectGetHeight(screen);
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityIndicator.frame=CGRectMake((width/2) - 10,(height/2) - 54, 20, 20);
activityIndicator.center=self.view.center;
[activityIndicator hidesWhenStopped];
[self playVideo];
}
-(void) playVideo
{
NSURL *url = [NSURL URLWithString:@"http://player.vimeo.com/video/32983838"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
[activityIndicator startAnimating];
[webView addSubview:activityIndicator];
}
/* WebViewDidStartLoad */
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[activityIndicator startAnimating];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}
/* WebViewDidFinishLoad */
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[activityIndicator stopAnimating];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
/* WebViewdidFailLoadWithError */
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
答案 2 :(得分:1)
如果我理解正确并且在上面的回应中,谷歌因版权侵权而关闭了几个“转换网站”:http://www.real.com/resources/youtube-to-mp3-converter还有其他网站可以下载视频内容(再次假设您已经过了根据版权指南):这列出了五个网站,您可以在这些网站免费查找和下载在线视频。要确保视频合法下载,请查找有关视频的许可信息。通常情况下,具有“知识共享”许可的视频下载是合法的,但可能会限制您使用视频的方式。 http://www.real.com/resources/download-one-video