将html5视频加载到Webview时出现问题 [英] Problem when load html5 videos into webview
问题描述
将html5加载到webview时出现问题. 我的第一个构建版本中的应用成功播放了视频,但是当我清除/杀死应用再次打开时,单击播放时Webview不会播放视频.
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>
- 源加载网页视图
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, "");
我研究并尝试解决此问题,但未成功
https://stackoverflow.com/questions/3815090/webview-and-html5-video
https://issuetracker.google.com/issues/36935939
v.v ..
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.
推荐答案
尝试一下:-
-
DashBoardFragment2.java:- https://drive.google.com/file/d/1UREa7uGrQYcF-ABzPktBSjUcOPtytxSC/view?usp = sharing
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
dashboard.xml :- https://drive.google.com/file/d/1LlgbdSe-9bgUU5lsGZUGOX3Tg7bnVpzH/view?usp=sharing
这篇关于将html5视频加载到Webview时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!