当前位置:网站首页>WebView opens H5 video and displays gray background or black triangle button. Problem solved

WebView opens H5 video and displays gray background or black triangle button. Problem solved

2022-04-23 18:43:00 KIDD-4869

Load normally :
 Insert picture description here

Treatment method :

 webView.setWebChromeClient(new WebChromeClient() {
    

            @Override
            public Bitmap getDefaultVideoPoster() {
    
                //modified by kxqin on 2020/7/17  load h5 video , Solve the problem of gray background and black triangle playing key 
                try{
    
                    // Default return null,  Replace here with a transparent picture , Does not affect playback .
                    return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
                }catch(Exception e){
    
                    return super.getDefaultVideoPoster();
                }
            }
 }           

tips: Repeated settings will overwrite the old , Because it's always new WebChromeClient, So use it on the outermost layer , The use of base classes may be covered by an outer layer , The pit has been stepped on .

版权声明
本文为[KIDD-4869]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210603464699.html