问题
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 :-
DashBoardFragment2.java :- https://drive.google.com/file/d/1UREa7uGrQYcF-ABzPktBSjUcOPtytxSC/view?usp=sharing
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