“不支持电影格式"在 iPhone 上使用 WebView 中的 YouTube 播放器 [英] "Movie Format Not Supported" on iPhone with YouTube player in a WebView

查看:44
本文介绍了“不支持电影格式"在 iPhone 上使用 WebView 中的 YouTube 播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iPhone 上使用 UIWebView 来播放 YouTube 视频.这在大多数情况下运行良好,但不是全部.

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

在某些情况下,显然与网络连接问题有关,错误不支持此电影格式".显示.在相同情况下,在 Safari 和 YouTube 播放器中都可以看到相同的错误.

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.

不幸的是,Apple 在 AppStore 测试期间发现了它,因此他们拒绝了该应用.

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?

感谢您的帮助,

拉里

推荐答案

如果您使用 YouTube 数据 API 并检查联合密钥,如果它为 TRUE,则视频应该播放.

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

当该值设置为 FALSE 时,表示该视频在移动设备上受到限制.

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

假设 youTubeResults 是一个 youtube jsonc 编码的 NSDictionary

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!");
}

此外,您可以尝试使用我开发的这个 uiwebview 类别,您可能会以与我不同的方式设置 uiwebview.因为,我还没有看到那个错误.

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

这篇关于“不支持电影格式"在 iPhone 上使用 WebView 中的 YouTube 播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆