“Movie Format Not Supported” on iPhone with YouTube player in a WebView

烂漫一生 提交于 2019-12-23 20:01:02

问题


I'm using a UIWebView on iPhone to play YouTube videos. This is working fine most of the time, but not all.

Under some circumstances, apparently related to network connection issues, the error "This movie format is not supported." is shown. This same error can be seen in both Safari and the YouTube player under the same circumstances.

Unfortunately it has been seen by Apple during the AppStore testing so they've rejected the app.

Can anyone suggest methods for detecting and handling the error more appropriately or alternatively any other video hosting system where we could get a similar experience without the player issue?

Thanks for your help,

Larry


回答1:


Try this code to see if it gives you any other hints 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];



回答2:


If you use the YouTube data api and inspect the syndicate key, if it's TRUE then the video should play.

When this value is set to FALSE, it indicates that the video is restricted on mobile devices.

Assuming youTubeResults is a youtube jsonc encoded NSDictionary

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

Also, you could try using this uiwebview category I've developed, you might be setting up the uiwebview differently that I do. As, I haven't seen that error.

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



来源:https://stackoverflow.com/questions/4315609/movie-format-not-supported-on-iphone-with-youtube-player-in-a-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!