Can anyone shed any light on why I'm unable to click and play a youtube clip on an Android handset when placed inside a webview?
任何人都可以了解为什么我放在网页浏览器中时无法点击并在Android手机上播放youtube剪辑?
I've put a very simple app together (it's being extended, but no right away) and it has a web view assigned using the Android SDK.
我把一个非常简单的应用程序放在一起(它正在扩展,但没有立即),它有一个使用Android SDK分配的Web视图。
The rest of the webview works as expected (text, images, css etc), however, the YouTube clips will not show, they just show as black or white rectangles (where the video embed should be).
webview的其余部分按预期工作(文本,图像,CSS等),但是,YouTube剪辑不会显示,它们只显示为黑色或白色矩形(视频嵌入的位置应该是)。
We use the same view to display content on the iPhone app equivalent, without any issues.
我们使用相同的视图在iPhone应用程序上显示相当的内容,没有任何问题。
This is using a basic flash embed, the Safari browser on iPhone converts these to H.264 and plays them nicely in QuickTime.
这是使用基本的Flash嵌入,iPhone上的Safari浏览器将这些转换为H.264并在QuickTime中很好地播放它们。
Can Android do the same??
Android能做同样的事吗?
Here is the embed code, as an example....
这是嵌入代码,作为一个例子....
<object width="120" height="73">
<param name="movie" value="http://www.youtube.com/watch?v=ZVYIBIlTIQs&feature=youtube_gdata"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/watch?v=ZVYIBIlTIQs&feature=youtube_gdata" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="120" height="73"></embed>
</object>
3 个解决方案
#1
14
I am not sure if this is what you need. Anyway I hope the following be useful. You can use the iframe method that youtube provides to play its videos. If the browser supports html5 will show the video with it, otherwise with flash.
我不确定这是否是你需要的。无论如何,我希望以下内容有用。您可以使用youtube提供的iframe方法播放视频。如果浏览器支持html5将使用它显示视频,否则使用flash。
You can use the following code as an example <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/bIPcobKMB94" frameborder="0">
您可以使用以下代码作为示例
in the above example the video id is bIPcobKMB94. You can change this id and show your video.
在上面的例子中,视频ID是bIPcobKMB94。您可以更改此ID并显示您的视频。
You can access a live example of it here
您可以在此处访问它的实例
More infromation for youtube iframe
更多关于youtube iframe的信息
YouTube HTML5视频播放器
#2
2
Unless the user has Froyo this is going to be impossible. However as long as the user has the YouTube app installed (which is standard for most phones I believe) then you can include a link to the YouTube video, and Android will recognize it as such and open it using the YouTube app. It's not as elegant as embedding, but it's much more reliable.
除非用户拥有Froyo,否则这将是不可能的。但是,只要用户安装了YouTube应用程序(这是我认为的大多数手机的标准配置),您就可以添加YouTube视频的链接,Android会识别它并使用YouTube应用程序打开它。它不像嵌入那么优雅,但它更可靠。
#3
0
You would need to have the flash player, which is only available since Android 2.2 (Froyo).
您需要拥有自从Android 2.2(Froyo)以来才能使用的Flash播放器。
#1
14
I am not sure if this is what you need. Anyway I hope the following be useful. You can use the iframe method that youtube provides to play its videos. If the browser supports html5 will show the video with it, otherwise with flash.
我不确定这是否是你需要的。无论如何,我希望以下内容有用。您可以使用youtube提供的iframe方法播放视频。如果浏览器支持html5将使用它显示视频,否则使用flash。
You can use the following code as an example <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/bIPcobKMB94" frameborder="0">
您可以使用以下代码作为示例
in the above example the video id is bIPcobKMB94. You can change this id and show your video.
在上面的例子中,视频ID是bIPcobKMB94。您可以更改此ID并显示您的视频。
You can access a live example of it here
您可以在此处访问它的实例
More infromation for youtube iframe
更多关于youtube iframe的信息
YouTube HTML5视频播放器
#2
2
Unless the user has Froyo this is going to be impossible. However as long as the user has the YouTube app installed (which is standard for most phones I believe) then you can include a link to the YouTube video, and Android will recognize it as such and open it using the YouTube app. It's not as elegant as embedding, but it's much more reliable.
除非用户拥有Froyo,否则这将是不可能的。但是,只要用户安装了YouTube应用程序(这是我认为的大多数手机的标准配置),您就可以添加YouTube视频的链接,Android会识别它并使用YouTube应用程序打开它。它不像嵌入那么优雅,但它更可靠。
#3
0
You would need to have the flash player, which is only available since Android 2.2 (Froyo).
您需要拥有自从Android 2.2(Froyo)以来才能使用的Flash播放器。