Reputation:
I want to show text, image and video in my application. For this issue I use webView
because I should show image and video between texts.
for set webView
I write this codes:
WebSettings settings = post_content_web.getSettings();
post_content_web.setWebChromeClient(new WebChromeClient());
settings.setPluginState(WebSettings.PluginState.ON);
settings.setJavaScriptEnabled(true);
settings.setDefaultTextEncodingName("utf-8");
String myCustomStyleString = "<style type=\"text/css\">@font-face {font-family: MyFont;src: " +
"url(\"file:///android_asset/fonts/iran_sans_mobile.ttf\")}body,* {font-family: MyFont; font-size: " +
"medium;text-align: justify;}</style>";
post_content_web.loadDataWithBaseURL("", myCustomStyleString + "<div style=\"direction:rtl\">"
+ title + "\n\n" + content + "</div>", "text/html", "utf-8", null);
I use Embed code from video, such as this :
<div id="14915658601813975"><script type="text/JavaScript" src="https://www.aparat.com/embed/hdvzs?data[rnddiv]=14915658601813975&data[responsive]=yes"></script></div>
My application shows video frame (border) and video thumbnail but when I click on video to play, does't show any video and just show black screen!!!!
How can I fix it?
Upvotes: 0
Views: 1584
Reputation: 1586
To support the video available in div tag(<div>
),
You will have to add some extra properties for WebView Settings.
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/cache");
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/databases");
I had the same issue, and adding this snippet solved BLACK SCREEN.
May this helps you too!
Upvotes: 1