Issue displaying thumbnail image in VideoView

China☆狼群 提交于 2019-12-06 02:12:43

VideoView is a subclass of SurfaceView, which has some special behaviors in terms of its display. SurfaceView contents are actually drawn in a window underneath the view hierarchy and the view simply acts as a hole in the current window so the contents are visible. Because of this, if you apply anything to the view itself (like a background), it will actually be Z-Ordered on top of the video content. In addition, if you place anything underneath the VideoView, it also will not be visible because of this "hole".

If you want to display content in this space while the video is not playing, it will either need to be in a separate View laid out on top of the VideoView that you can hide/show when the video playback state changes, or you need to set/clear the background image you have set when the video playback state changes.

HTH!

Use this code

BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmapImage);
            videoview.setBackgroundDrawable(bitmapDrawable);
        videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                public void onPrepared(MediaPlayer mp) {

                    videoview.setBackgroundDrawable(null);
                }
            });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!