无法使用 sdcard 中的 webview 播放 html 视频
我想从 sdcard 在 webview 中播放视频。我用谷歌搜索但无法找到解决方案。我尝试过这种方式:
public class WebActivity extends Activity {
private WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.helpview);
mWebView =(WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.getSettings().setBuiltInZoomControls(true);
String html ="<html><head></head><body>Playing Video<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file://"+Environment.getExternalStorageDirectory()+"/test-embeded.swf\"> <embed src=\"file://"+Environment.getExternalStorageDirectory()+"/test-embeded.swf"+"\" width=\"550\" height=\"400\"> </embed> </object></body></html>";
String mimeType = "text/html";
String encoding = "utf-8";
mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
}
}
我得到的输出为空白屏幕。
我什至安装了 Adope Flash Player 10.1.apk 但输出仍然是这样,
有人知道解决方案吗?
I want to play video in webview from sdcard. I googled but could not get solution.I have tried this way:
public class WebActivity extends Activity {
private WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.helpview);
mWebView =(WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.getSettings().setBuiltInZoomControls(true);
String html ="<html><head></head><body>Playing Video<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file://"+Environment.getExternalStorageDirectory()+"/test-embeded.swf\"> <embed src=\"file://"+Environment.getExternalStorageDirectory()+"/test-embeded.swf"+"\" width=\"550\" height=\"400\"> </embed> </object></body></html>";
String mimeType = "text/html";
String encoding = "utf-8";
mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
}
}
I got output as a blank screen.
I have even installed Adope Flash Player 10.1.apk
but still the output is like that only
Could anybody know the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经在 webview 中加载了一个 html 页面,其中包含视频标签,并且我得到了输出。 html 文件位于 \assets 文件夹中,这是我的代码,它可能对您有帮助,
我的 html 页面是,
I have load a html page in a webview, which contain video Tag and i got the output. html file is in \assets folder, Here is my code it may help you,
And my html page is,
很多事情都可能出错。
首先,检查AndroidManifest.xml。你有包括在内吗
?
接下来,检查日志(adb logcat)中的错误并将其发布到此处
A number of things could go wrong.
First, check in AndroidManifest.xml. Do you have included
?
Next, check for errors in the log (adb logcat) and post them here