如何在iOS中播放Vimeovideo?

我试图search到networking,但是我找不到一个不超过1年的话题,因此,

如何在iOS应用程序中播放Vimeovideo?

编辑1:当使用解决scheme时,我有时从Vimeo得到这个HTTP响应

在这里输入图像说明

为什么?

这是我在应用程序中播放Vimeovideo的方式。

我正在使用iFrame在我的应用程序中加载Vimeovideo。

按照这个步骤,你也会。

创build一个uiwebview并将其连接到你的.h文件。 我的是_webView。

将此方法添加到.m文件。

 -(void)embedVimeo{ NSString *embedHTML = @"<iframe width=\"300\" height=\"250\" src=\"http://www.vimeo.com/embed/rOPI5LDo7mg\" frameborder=\"0\" allowfullscreen></iframe>"; NSString *html = [NSString stringWithFormat:embedHTML]; [_webView loadHTMLString:html baseURL:nil]; [self.view addSubview:_webView]; } 

我正在使用Vimeovideo中的embedded式代码。 (我希望你知道这是什么)

在你的viewdidload中调用这个方法

 [self embedVimeo]; 

运行应用程序,您将在视图中看到video。 这种方式对我来说是完美的,我认为这对你也有帮助。

你可以使用YTVimeoExtractor ,对我来说工作正常。

你可以使用这个代码

 NSString *htmlStringToLoad = [NSString stringWithFormat:@"http://player.vimeo.com/video/%@?title=0&amp;byline=0&amp;portrait=0\%%22%%20width=\%%22%0.0f\%%22%%20height=\%%22%0.0f\%%22%%20frameborder=\%%230\%%22", videoID]; [aWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:htmlStringToLoad]]]; 

请尝试一下 ,它适用于我,只是一些代码行。

 - (void)viewDidLoad { [super viewDidLoad]; vimeoHelper = [[VimeoHelper alloc] init]; [vimeoHelper getVimeoRedirectUrlWithUrl:@"http://vimeo.com/52760742" delegate:(id)self]; } - (void)finishedGetVimeoURL:(NSString *)url { _moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]]; [self presentViewController:_moviePlayerController animated:NO completion:nil]; } 

使用下面的代码,它会正常工作

 NSMutableString *html = [[NSMutableString alloc] initWithCapacity:1] ; [html appendString:@"<html><head>"]; [html appendString:@"<style type=\"text/css\">"]; [html appendString:@"body {"]; [html appendString:@"background-color: transparent;"]; [html appendString:@"color: white;"]; [html appendString:@"}"]; [html appendString:@"</style>"]; [html appendString:@"</head><body style=\"margin:0\">"]; [html appendString:@"<iframe src=\"//player.vimeo.com/video/84403700?autoplay=1&amp;loop=1\" width=\"1024\" height=\"768\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"]; [html appendString:@"</body></html>"]; [viewWeb loadHTMLString:html baseURL:urlMovie]; 

我用这个代码:

 NSString *embedSr = @"<iframe width=\"304\"height=\"350\" src=\"http://player.vimeo.com/video/... \" frameborder=\"0\" allowfullscreen></iframe>"; [[self WebView] loadHTMLString:embedSr baseURL:nil]; 

我已经尝试了通用播放器 ,它在iOS 5的设备上成功,但在iOS 4.2的iPhone 3G上失败。 我不知道为什么。 这里是embedded它的链接。

或者,您可以从Vimeo网站手动embedded,单击embedded,并根据需要configurationconfiguration。