如何嵌入在Android上的WebView一个YouTube视频 [英] How to embed a YouTube clip in a WebView on Android

查看:170
本文介绍了如何嵌入在Android上的WebView一个YouTube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释为什么我无法点击,并在Android手机玩YouTube视频时,放置一个web视图中的任何轻?

我已经把(它被延长,但没有马上)一个非常简单的应用程序,它有使用Android SDK指定的Web视图。

web视图的其余部分按预期方式工作(文本,图像,CSS等),然而,YouTube视频将不会显示,它们仅示出为黑色或白色的矩形(在视频嵌入应)。

我们使用了同样的看法,显示在iPhone上的应用程序当量含量,没有任何问题。

这是使用基本的Flash嵌入,iPhone上的Safari浏览器将这些为H.264,并很好地发挥他们的QuickTime。

可以的Andr​​oid做同样??

这里是嵌入code,作为一个例子....

 <对象的宽度=120HEIGHT =73>
    < PARAM NAME =电影值=htt​​p://www.youtube.com/watch?v=ZVYIBIlTIQs&feature=youtube_gdata>< /参数>
    < PARAM NAME =的allowFullScreen值=真>< /参数>
    < PARAM NAME =allowScriptAccess的值=始终>< /参数>
    <嵌入SRC =htt​​p://www.youtube.com/watch?v=ZVYIBIlTIQs&feature=youtube_gdata类型=应用程序/ x-冲击波闪光的allowScriptAccess =永远的allowFullScreen =真正的宽度= 120HEIGHT =73>< /嵌入>
&所述; /对象>
 

解决方案

我不知道这是否是你所需要的。无论如何,我希望下面是有用的。 您可以使用的iframe方法的YouTube提供发挥其视频。如果浏览器支持HTML5将显示它的视频,否则有闪光灯。

您可以使用下面的code,例如,< IFRAME类=YouTube的播放器类型=text / html的WIDTH =640HEIGHT =385SRC = http://www.youtube.com/embed/bIPcobKMB94FRAMEBORDER =0>

在上面的例子中视频id是bIPcobKMB94。您可以更改此ID,并显示您的视频。

您可以访问一个活生生的例子吧这里

更多infromation YouTube的IFRAME

YouTube的HTML5视频播放器

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?

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.

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).

We use the same view to display content on the iPhone app equivalent, without any issues.

This is using a basic flash embed, the Safari browser on iPhone converts these to H.264 and plays them nicely in QuickTime.

Can Android do the same??

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>

解决方案

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.

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.

You can access a live example of it here

More infromation for youtube iframe

YouTube HTML5 Video Player

这篇关于如何嵌入在Android上的WebView一个YouTube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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