Android VideoView black screen

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

    Just show a frame from the video as preview.

    vSurface.SeekTo(100);
    
    0 讨论(0)
  • 2020-11-27 13:36

    Use svVideoView.seekTo(position).

    Give Position within 5 (ms).

    onPause():
    position=svVideoView.getCurrentPosition()
    
    onResume():
    svVideoView.seekTo(position);
    
    0 讨论(0)
  • 2020-11-27 13:36

    see this

    VideoView videoView = (VideoView) findViewById(R.id.VideoView);
            MediaController mediaController = new MediaController(this);
            mediaController.setAnchorView(videoView);
            Uri video = Uri.parse("android.resource://your_package_name/"+R.raw.monkeysonthebed_video);
    
            videoView.setMediaController(mediaController);
            videoView.setVideoURI(video);
            videoView.start();
    
    0 讨论(0)
  • 2020-11-27 13:37

    Just use VideoView#setBackgroundDrawable(), I think.

    1. initial settings.

      VideoView.setBackgroundDrawable(yourdrawableid);
      
    2. start video

      VideoView.start();
      VideoView.setBackgroundDrawable(0);
      
    0 讨论(0)
  • It works for me on both Activity and Fragment.

    VideoView mVideo = (VideoView) findViewById(R.id.yourViewViewId);
              mVideo.setVideoURI(mUri);
              mVideo.setZOrderOnTop(false);
    
    SurfaceHolder surfaceholder = mVideo.getHolder();
    surfaceholder.setFormat(PixelFormat.TRANSPARENT);
    
    0 讨论(0)
  • 2020-11-27 13:38

    I had the same problem on Galaxy tab 2, Android 4.1.1.

    Do videoView.setZOrderOnTop(true); and next videoView.start()

    It works fine for me.

    0 讨论(0)
提交回复
热议问题