在 WebView 中播放 YouTube 视频 [英] play youtube video in WebView

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

问题描述

在我的 android 应用程序中,我有一个 WebView 来显示来自我们网站的 html 数据.有时页面会有 youtube 嵌入对象.这在应用程序中没有正确显示.有没有办法在 WebView 中显示/播放 youtube 视频?谢谢.

In my android app I have a WebView to display html data from our website. Sometimes the page will have youtube embed objects. This doesn't show up properly in the app. Is there any way to show/play youtube videos in WebView ? Thanks.

推荐答案

除非在具有 Flash 的设备上,否则您无法将它们嵌入显示.

You cannot show them embedded except perhaps on devices that have Flash.

但是,如果您可以解析出 YouTube 视频详细信息,您就可以构建一个 ACTION_VIEW Intent 将它们显示在 YouTube 应用程序上...那些装有 YouTube 应用程序的 Android 设备.

However, if you can parse out the YouTube video details, you may be able to construct an ACTION_VIEW Intent that will show them on the YouTube application...for those Android devices that have the YouTube application.

您还可以尝试使用 HTML5 的 标签,该标签在浏览器应用程序中受支持,因此可以在 WebView 中使用.

You might also experiment with HTML5's <video> tag, which AFAIK is supported in the Browser application and may therefore work in WebView.

这篇关于在 WebView 中播放 YouTube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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