IFRAME>如何在web视图通过&LT播放视频; Android中? [英] How to play Video in Webview via a <iframe> in Android?

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

问题描述

我需要的WebView播放YouTube视频,链接到视频是我的标签present。但是,当我跑我的应用程序,只有照片(缩略图)进来与它播放图标的地方,点击它后,它显示了一个黑色的屏幕上有一个搜索栏在00:00的时候,和加载符号就可以了,但后来什么也没有发生或所示。它比仍然出现了一整天。

I need to play a youtube video in webview, the link to the video is present in my tag. But when I run my application, only a pic(thumbnail) comes in the place with play icon on it, and after clicking on it, it shows a black screen with a seekbar on it at 00:00 time, and loading symbol on it, but then nothing happens or is shown. It than remains there all day.

我用的模拟器是 4.4的Andr​​oid。

我的code是如下: -

My code is a follows:-

WebView content = (WebView)findViewById(R.id.webView1);
String html="<html><body>Some text goes here<br>"
            + "<iframe src=\"//www.youtube.com/embed/eu9kMIeS0wQ?rel=0\" height=\"360\" width=\"640\" allowfullscreen=\"\" frameborder=\"0\"/></iframe></body></html>";
    content.getSettings().setPluginState(PluginState.ON_DEMAND);
    content.getSettings().setJavaScriptEnabled(true);
    content.getSettings().setAllowFileAccess(true);
    content.setWebChromeClient(new WebChromeClient());
    content.setWebViewClient(new WebViewClient());
content.loadDataWithBaseURL("SomeStringForBaseURL", html, "text/html", "UTF-8", "");

我也包括了

的android:hardwareAccelerated =真>在清单

android:hardwareAccelerated="true"> In the manifest.

我是否需要添加任何API对YouTube或其他任何事情。或者我开始什么样的错误?任何帮助将AP preciated。先谢谢了。

DO I need to add any API's for Youtube or for any other thing. or what sort of mistake I am commencing? Any help will be appreciated. Thanks In Advance.

推荐答案

那么一切都很好,视频运行很好,速度很快。好了,模拟器需要安装Flash播放器,而这code使得在Android设备上播放的视频。如果有人需要源$ C ​​$ C,就可以使用上面的一个标签通过在Android上运行的WebView中的视频。

Well everything is fine, and the video is running nice and fast. Well, the emulator requires flash player to be installed, whereas this code makes videos playable on android devices. If anyone needs the source code, they can use the one above for running the videos in WebView via tag on android.

这篇关于IFRAME&GT;如何在web视图通过&LT播放视频; Android中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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