Android VideoView black screen

前端 未结 22 2049
清歌不尽
清歌不尽 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:25

    I meet the same problem, and solve it with the accepted solution above plus this:

      @Override
      public void onPrepared(MediaPlayer mp) {
        mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
          @Override
          public boolean onInfo(MediaPlayer mp, int what, int extra) {
            Log.d(TAG, "onInfo, what = " + what);
            if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
              // video started; hide the placeholder.
              placeholder.setVisibility(View.GONE);
              return true;
            }
            return false;
          }
        });
    

    I think onPrepared just means the video is ready to play, but not means video started playing. If hide placeholder in onPrepared, the screen still show a black screen.

    On my Note3 and Nexus, this solution works well.

提交回复
热议问题