Я загрузил html-страницу в веб-просмотр, который содержит видео-тег, и я получил вывод.HTML-файл находится в папке \ assets, вот мой код, который может вам помочь,
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webview);
String html = "<embed src=\"file:///android_asset/" + "demo.html" + " \"play=\"true\" loop=\"true\" width=\"100%\" height=\"100%\"> <embed>";
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
WebViewClient webViewClient = new WebViewClient();
webView.setWebViewClient(webViewClient);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
}
@Override
public void onLoadResource(WebView view, String url) {
if (url.endsWith(".mp4")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri
.parse(url));
intent.setDataAndType(Uri.parse(url), "video/*");
view.getContext().startActivity(intent);
}
else
{
super.onLoadResource(view, url);
}
}
});
}
И моя HTML-страница,
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset=utf-8>
<title>Sample HTML5 Structure</title>
<SCRIPT LANGUAGE="JavaScript">
function playvideo(url)
{
window.location=url;
}
</SCRIPT>
</head>
<body>
<video src="file:///sdcard/video.mp4" width="300" onclick="playvideo('file:///sdcard/video.mp4')" height="150" controls>
<p>If you are reading this, it is because your browser does not support the HTML5 video element.</p>
</video>
</body>
</html>