"Video format not supported" on iPhone with YouTube player in WebView

I am using UIWebView on iPhone to play YouTube videos. This works fine, but not all.

In some circumstances, apparently related to network connectivity issues, the error "This movie format is not supported." Shown. The same error can occur in Safari and in the YouTube player under the same circumstances.

Unfortunately, this was noticed by Apple during testing of the AppStore, so they rejected the application.

Can someone suggest methods for detecting and processing errors in a more appropriate way or, alternatively, any other video hosting system where we could get a similar experience without a problem with the player?

Thank you for your help,

Larry

+3
source share
2 answers

Try this code to see if it gives any other clues about the problem:

// report the error inside the webview
    NSString* errorString = [NSString stringWithFormat:
                             @"<html><center><font size=+5 color='white'>An error occurred:<br>%@</font></center></html>",
                             error.localizedDescription];
    [self.webView loadHTMLString:errorString baseURL:nil];
0
source

If you use the api data on YouTube and check the syndicate key, if it is TRUE, then the video should play.

If this value is set to FALSE, this means that video is restricted on mobile devices.

Assuming youTubeResults is an NSDictionary jtc encoded by youtube

if (![[[[[[youTubeResults objectForKey:@"data"]
                         objectForKey:@"items"]
                         objectAtIndex:index]
                         objectForKey:@"accessControl"]
                         valueForKey:@"syndicate"] isEqualToString:@"allowed"]){
    NSLog(@"video won't play on mobile!");
}

In addition, you can try to use this uiwebview category that I developed, you can configure uiwebview in a different way, what I do. Since, I did not see this error.

https://github.com/enigmaticflare/UIWebView-YouTube--iOS-Category--ARC-compliant-code

0

Source: https://habr.com/ru/post/1777692/


All Articles