Android VideoView black screen

前端 未结 22 2116
清歌不尽
清歌不尽 2020-11-27 12:55

I have been looking for a way to get rid of the nasty black initial screen on a VideoView before the start() method is run.

I have tried with background image on the

22条回答
  •  囚心锁ツ
    2020-11-27 13:27

    This is definitely hacky, but better than overlaying an image (IMO).

    boolean mRestored = false;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        mRestored = savedInstanceState != null;
    }
    
    @Override
    public void onPrepared(MediaPlayer mp) {
    
        if (!mRestored) vSurface.seekTo(1);
    }
    

    Assuming you are putting things into savedInstanceState in onSaveInstanceState.

提交回复
热议问题