Android webview 无法呈现通过 iframe 嵌入的 youtube 视频 [英] Android webview cannot render youtube video embedded via iframe

查看:60
本文介绍了Android webview 无法呈现通过 iframe 嵌入的 youtube 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于在 web 视图中使用最新的嵌入式格式 (iframe) 加载 youtube 视频.

This is about loading youtube videos using latest embedded format (iframe) inside a webview.

iframe 嵌入格式示例

Example of the iframe embed format

<iframe width="637" height="358" src="http://www.youtube.com/embed/olC42gO-Ln4?fs=1&amp;feature=oembed" frameborder="0" allowfullscreen=""></iframe>

在 Android 2.3.3 & 上测试代码3.2 设备(HTC Desire & Asus Transformer),webview 只会显示一个黑色矩形.

Test the code on Android 2.3.3 & 3.2 devices (HTC Desire & Asus Transformer), the webview would only show a black rectangle.

我尝试了类似的 vimeo 嵌入

I tried a similar embed from vimeo

<iframe src="http://player.vimeo.com/video/35693267" width="640" height="360" frameborder="0"></iframe>

在 2.3 中,视频正常播放
3.2中,一个黑色矩形闪烁消失,iframe区域为空白.

In 2.3, video played correctly
In 3.2, a black rectangle flashed and disappeared, the iframe area is blank.

最后,如果使用旧的嵌入格式(使用对象标签),则视频在 2.3.3 和 2.3.3 和3.2.

Finally if the old embed format (using the object tag) is used, the video is displayed properly inside the webview in both 2.3.3 & 3.2.

我已经检查了相关问题并添加了

I have checked related questions and added

android:hardwareAccelerated="true"

在应用程序和/或活动标签中,但在 2.3 和 2.3 中仍然没有视频3.2 设备.

in the application and/or activity tag but still no video in both 2.3 & 3.2 devices.

这是一个大问题,因为现在越来越多的网站使用最新的格式 (iframe) 来嵌入他们的 youtube 视频.Android/Youtube 团队,请看一下这个问题.

This is a big problem because more websites are now using the newest format (iframe) to embed their youtube videos. Android/Youtube Team, please take a look at this problem.

推荐答案

Android 浏览器在视频播放和嵌入方面完全有问题.它根本无法跨设备工作.试图让它工作只是浪费你的时间.我的建议是,您不要尝试包含 <iframe>,而只需提供直接链接到 YouTube 页面或 h264 文件的视频缩略图.

Android browsers are utterly buggy what comes to video playback and embedding. It simply does not work across devices. Trying to get it working is just waste of your time. My suggestion is that you don't try to include <iframe> but simply provide a thumbnail of the video which directly links to YouTube page or h264 file.

之前的讨论,以及可能的解决方案.

Earlier discussion, with a possible solution.

Google Reader-esque 在 Android 上优化 WebView

这篇关于Android webview 无法呈现通过 iframe 嵌入的 youtube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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