Android - 如何在 WebView 中播放 Youtube 视频? [英] Android - How to play Youtube video in WebView?

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

问题描述

我需要在 webview 中播放 youtube 视频,但是当我加载 URL 时,整个 youtube 移动页面都被加载了.我只想要一个播放器或一种将视频嵌入 webview 的方法,就像在 IOS 中一样.是否可以?使用 iframe 标签,视频无法加载,它表示发生了错误.谢谢.

I need to play youtube video in the webview,but when I load the URL the entire youtube mobile page is loaded. I want only a player or a way to embed the video in the webview, like in IOS. Is it possible? With the iframe tag the video doesn't load, it say that an error occurred. Thanks.

推荐答案

使用代码在 WebView 的源中显示嵌入的视频:

Use the Code to display an embedded Video in your Source for the WebView:

<iframe width="560" height="315" src="http://www.youtube.com/embed/...." frameborder="0" allowfullscreen></iframe>

如果您访问 Youtube 网站并单击共享 -> 嵌入,则可以找到 src-Tag 的 URL.

但是为什么要使用 WebView?在那里你必须在 Flash 中播放视频.Android VideoView 还可以流式传输 Youtube 视频.

You can find the URL for the src-Tag if you got to the Youtube Website and click on share -> embed.

But why do you use WebView? There you have to play the Videos in Flash. The Android VideoView can also stream Youtube Videos.

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

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