How do I remove the overlay play icon (triangle) that's visible in the center of the video for a second or so every time a video starts playing in an Android WebView?
Thanks in advance!
How do I remove the overlay play icon (triangle) that's visible in the center of the video for a second or so every time a video starts playing in an Android WebView?
Thanks in advance!
If you said about this picture
This is picture I had when tested my app on Android 6.0.
You can hide this picture. For example:
WebView mWebView = (WebView) findViewById(R.id.web_view);
mWebView.setWebChromeClient(new WebChromeClientCustomPoster());
Chrome client class:
private class WebChromeClientCustomPoster extends WebChromeClient {
@Override
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
}
}
More info read api
I found a solution. Just add the 'poster' attribute.
e.g. poster="https://via.placeholder.com/1x1"
or poster="noposter"
Note: Empty value are ignored. (poster=""
)
Please note that setting poster
to an invalid URL (such as "noposter") might trigger a network call and an error
event from the video player.
In my projects, I'm setting the poster to a tiny transparent GIF:
poster="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
Neither poster="noposter"
nor poster="null"
work for me.
I made it work by creating a placeholder image that has just a white background color and assigned it to the video per DOM.
document.getElementById("myVideo").poster = "noposter.png";