2

I've tried to search to web, but I couldn't find a topic not older than 1 year regarding this problem, therefore;

How can I play a Vimeo video in an iOS App?

EDIT1: When using the solution I'm sometimes getting this HTTP response from Vimeo

enter image description here

Why?

Community
  • 1
  • 1
dhrm
  • 14,335
  • 34
  • 117
  • 183

7 Answers7

9

This is my way of play a Vimeo video inside a app.

I am using iFrame to load Vimeo video inside my app.

follow this steps and you will too.

create a uiwebview and connect it to your .h file. Mine is _webView.

Add this method to your .m file.

-(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];
}

I am using the embedded code in Vimeo video. (I hope you know what it is)

call this method inside your viewdidload

[self embedVimeo];

Run the app and you will see the video in your view. This way is perfectly working for me and i think this will help for your too.

Sameera Chathuranga
  • 3,638
  • 3
  • 27
  • 48
7

You can use YTVimeoExtractor, works fine for me.

Louis Larpin
  • 99
  • 1
  • 2
2

Please try this, It works for me, just some lines of code.

- (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];
}
Mostafa Berg
  • 3,211
  • 22
  • 36
user1140633
  • 103
  • 7
2

You can use this code

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]]];
Xavi López
  • 27,550
  • 11
  • 97
  • 161
NadavN7
  • 367
  • 1
  • 9
  • Thanks for your solution. But it seems that this only works with some videos? For my video I get this message "This video can't be played with your setup" whereas other videoes are working fine (like this http://vimeo.com/32424117). Why? – dhrm Nov 29 '11 at 09:33
  • Do I need a Vimeo Plus account? – dhrm Nov 29 '11 at 09:59
  • I don't know really, in YouTube I know there is some videos that is private videos or restricted to some regions, therefore they cannot be embedded. Anyway,try to work with Vimeo API(for iOS), and fetch the error received from server. – NadavN7 Nov 29 '11 at 11:10
  • Downvoted this ``UIWebView`` solution, because it's way better to use ``MPMoviePlayerController`` instead of the large webkit. – Christian Beer Mar 18 '13 at 10:03
  • @ChristianBeer sure, but that is not always possible. – Jon Willis Oct 08 '13 at 18:11
1

I've used this code:

NSString *embedSr = @"<iframe width=\"304\"height=\"350\" src=\"http://player.vimeo.com/video/... \" frameborder=\"0\" allowfullscreen></iframe>";

[[self WebView] loadHTMLString:embedSr baseURL:nil];
Kundan
  • 3,084
  • 2
  • 28
  • 65
MADPT
  • 97
  • 2
  • 12
1

Use Below Code the it will work fine

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];
Prabhjot Singh Gogana
  • 1,408
  • 1
  • 14
  • 39
0

I've tried the universal player, it is successful in device with iOS 5, but failed in iOS 4.2 with iPhone 3G. I don't know why. Here's the link to embed it.

Or you can embed manually from the Vimeo site, click embed, and configure the config as you wish.

Mohsin Khubaib Ahmed
  • 1,008
  • 16
  • 32
mamaz
  • 25
  • 7