Youtube videos embedded in Android Webview cannot play in SINGLE_COLUMN layout

I am trying to load some HTML data into Android Webview. The data is in the form of a string downloaded from a web service, and the HTML may contain embedded YouTube videos that I want to embed in a row and make playable.

Everything works fine with LayoutAlgorithm.NORMAL . But when I use the SINGLE_COLUMN layout SINGLE_COLUMN , Youtube videos appear as black boxes that can no longer be played. I need one column format, since images inside HTML overflow the width of the web view in NORMAL mode. Here is my code for setting up webview.

 // Set maximum image width to fit screen contentWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); // Make non focusable to prevent links from being selectable. contentWebView.setFocusableInTouchMode(false); contentWebView.setFocusable(false); // Enable HTML5 video contentWebView.getSettings().setJavaScriptEnabled(true); contentWebView.getSettings().setPluginState(PluginState.ON); contentWebView.setWebChromeClient(new WebChromeClient() { }); 

Is it possible to somehow make the video playable with the SINGLE_COLUMN layout or to emulate the layout of one column manually using the NORMAL layout algorithm? Any other ideas?

+4
source share
1 answer

LayoutAlgorithm.SINGLE_COLUMN - Deprecated by Google developers. You can change the width / height of the elements in your html string if you can.

In my case, I replace all height = ", width =" "- and it works fine without setLayoutAlgorithm () settings. Or try this solution

0
source

Source: https://habr.com/ru/post/1494465/


All Articles