Android VideoView black screen

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

    None of the Above worked for me. In my case, onPrepared gets called BEFORE the black frame went away, so I would still see the black frame.

    I needed a solution where the video appeared shortly after the first frame.

    So what I did was set the VideoView alpha to 0 in xml:

    android:alpha="0"
    

    and then before I start the video I animate the alpha back to 1:

    videoView.animate().alpha(1);
    videoView.seekTo(0);
    videoView.start();
    

    alternatively, you can just post a delayed Runnable to set the alpha to 1, instead of animating it.

提交回复
热议问题