Problem when load html5 videos into webview

别等时光非礼了梦想. 提交于 2019-12-11 18:28:33

问题


I have a problem when load html5 into webview. My app in first build play video success but when i clear/kill app open again, webview not play video when click play.

  • Html5
<video src="url.mp4" controls poster="thumbnail.jpg" style="max-width: 100%;"><a href="url.mp4">Download video</a></video>
  • Source load webview
WebView webView = new WebView(context);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient());

String html = "<html><head><link rel='stylesheet' href='file:///android_asset/css/style.css'></head><body>"
+ htmlElement.getContent()
+ "</body></html>";
webView.loadDataWithBaseURL("file:///android_asset/", html, mimetype, encoding, "");

I research and try fix this issue but not success https://stackoverflow.com/questions/3815090/webview-and-html5-video https://issuetracker.google.com/issues/36935939 v.v..

Anyone has the same my problem? Thanks.


回答1:


Try this :-

  1. DashBoardFragment2.java :- https://drive.google.com/file/d/1UREa7uGrQYcF-ABzPktBSjUcOPtytxSC/view?usp=sharing

  2. dashboard.xml :- https://drive.google.com/file/d/1LlgbdSe-9bgUU5lsGZUGOX3Tg7bnVpzH/view?usp=sharing



来源:https://stackoverflow.com/questions/55842151/problem-when-load-html5-videos-into-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!