Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable default ugly poster image in html5 video tag on android

On android, using html5 video tag to load a video, before video loads, the placeholder image is a grayish image with a big "play" icon on it, suppose I don't have a poster image for the video so I couldn't replace it, is there any way I could disable the ugly one?

like image 681
Shawn Avatar asked Oct 05 '16 13:10

Shawn


1 Answers

I know this question is old, but I was looking for the answer to this. It turns out that WebChromeClient has a getDefaultVideoPoster method. So you can do something like:

webView.setWebChromeClient(new WebChromeClient() {
    @Override public Bitmap getDefaultVideoPoster() {
        final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        // Use whatever color you want here. You could probably use a transparent color
        canvas.drawARGB(255, 0, 0, 0);
        return bitmap;
    }
});

I wouldn't necessarily make new bitmaps for every possible time this method could be called, but I'm sure you get the idea.

like image 56
2 revs Avatar answered Sep 30 '22 18:09

2 revs