Android VideoView black screen

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

    To avoid annoying flickering and black screen issues I wrote FrameVideoView.

    It takes benefits from 'placeholder solution' and (if your device is running API level 14 or higher) from TextureView, which is much more efficient than VideoView.

    I wrote article on our blog to cover what it actually does.

    It's simple to use:

    Add FrameVideoView to layout:

    
    

    find its instance in Activity and call corresponding methods in onResume and onPause:

    public class SampleActivity extends Activity {
    
      private FrameVideoView videoView;
    
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple);
    
        String uriString = "android.resource://" + getPackageName() + "/" + R.raw.movie;
        videoView = (FrameVideoView) findViewById(R.id.frame_video_view);
        videoView.setup(Uri.parse(uriString), Color.GREEN);
      }
    
        @Override
        protected void onResume() {
          super.onResume();
          videoView.onResume();
        }
    
        @Override
        protected void onPause() {
          videoView.onPause();
          super.onPause();
        }
      }
    

提交回复
热议问题