WebView 中的 Youtube 视频无法加载
授予了权限
<uses-permission android:name="android.permission.INTERNET"/>
我在我的 Activity 中实现了一个 WebView,为此我已使用以下代码
WebView mWebView;
mWebView = (WebView) findViewById(R.id.ueber_webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("file:///android_asset/MyTestPage.htm");
: html 页面正在正在加载 *well *,还显示视频及其边框和视频中心的典型 Youtube 播放按钮。但是当我按下它时,视频无法*加载*。
这是 htm 内容:
<div id="playerFrame">
<iframe src="http://www.youtube.com/embed/MyURL" //have to hide the url, ends with something like "...j4Fs?rel=0"
frameborder="0" allowfullscreen id="playerPlaceHolder"></iframe>
</div>
css 内容必须正确,因为它可以正确显示,这不应该是问题。
有什么帮助吗?
I've implemented a WebView in my Activity, for that I've given the permission
<uses-permission android:name="android.permission.INTERNET"/>
with this code:
WebView mWebView;
mWebView = (WebView) findViewById(R.id.ueber_webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("file:///android_asset/MyTestPage.htm");
The html page is loading *well*, also the are displayed the video with its border and the typical Youtube-Play-Button in the center of the video. But when I press it, the video doesn't *load*.
This is the htm content:
<div id="playerFrame">
<iframe src="http://www.youtube.com/embed/MyURL" //have to hide the url, ends with something like "...j4Fs?rel=0"
frameborder="0" allowfullscreen id="playerPlaceHolder"></iframe>
</div>
The css content must be correct cause it's displayed correctly, that shouldn't be the problem.
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在它可以工作了,结合了一些东西:
清单中的这些条目:
但我不知道,哪一个至少是必要的。此外,无法跳过视频的某些部分,我必须一口气看完。有人知道解决办法吗?
和MyOwnWebViewClient:
Now it works, with a combination of some things:
And these entries in the manifest:
But I don't know, which one are at least necessary. Further, it's not possible to skip parts of the video, I have to watch it in one turn. Anyone knows a solution?
And MyOwnWebViewClient:
我遇到了同样的问题,我在 github 上分享了我的代码。您需要做的就是调用这行代码:-
它也支持纵向模式。
I was facing same problem I have shared my code on github. All you need to do is call this line of code :-
It support portrait mode as well.