Search code examples
uiwebviewvimeoios9

Vimeo not running in UIWebView on iOS 9


I have a UIWebView embedded within a UIScrollView displaying a Vimeo video:

vimeoView = [[UIWebView alloc] init];    
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=\"https://player.vimeo.com/video/%@?title=0&byline=0&portrait=0&badge=0&loop=1\" width=\"%0.0f\" height=\"%0.0f\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"];
                        [html appendString:@"</body></html>"];

                        NSString *htmlString = [NSString stringWithFormat:html, videoID, vimeoView.frame.size.width, vimeoView.frame.size.height];

                        [vimeoView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"https://vimeo.com"]];

This code is compiled using Xcode 7 and distributed via the App Store (in beta mode, of course). The app runs fine on iOS 8, but on iOS 9 it hangs at 0s after it launches full screen.

Anyone out there got it working on iOS 9? I want to avoid using the Exception for HTTPS switch (or at least use just a narrow exception for specified servers). FWIW, NSAllowsArbitraryLoads = YES doesn't fix this problem anyway.


Solution

  • Here's the response I received from Vimeo support:

    We’re in the process of migrating between CDNs so I’m curious if that has anything to do with what you’re seeing.

    For example, can you try this video: https://vimeo.com/76979871, which is located on our older CDN;

    and this video: https://vimeo.com/139107494, located on our newer CDN.

    For me, this worked in that the video on the newer CDN worked fine in my app, the video on the older CDN did not. However, I have not heard back on whether/when old CDN videos will be migrated to the new CDN.

    ----- Update from Vimeo support 9/22:

    Webviews in iOS 9 will not load insecure content (HTTP) over a secure connection (HTTPS). When playing back older videos, which are hosted on our older CDN, some content is still served over HTTP. More recently uploaded videos have all their assets served over HTTPS, and will play back fine in iOS 9 webviews.

    Does your app feature videos only from your Vimeo account, or does it also display videos from others? If you’re only using your own videos in your app, I recommend uploading those videos again; they should automatically go to our newer CDN where all the assets are served over HTTPS.

    We’re in the process of moving videos from our older CDN onto our newer CDNs, but there’s no public timeframe for how long this will take.