VideoView onResume loses buffered portion of the video

后端 未结 10 547
北恋
北恋 2020-12-01 02:56

I am having an Activity in which there is

  1. VideoView -- Streams a video from a webserver.

  2. Button -- Takes the user to the next activit

10条回答
  •  无人及你
    2020-12-01 03:46

    As the buffer is lost when the video view goes to the background(change in visibility), you should try blocking this behavior by overriding the onWindowVisibilityChanged method of VideoView. Call super only if the video view is becoming visible. May have side-effects.

    public class VideoTest extends VideoView {
    
        public VideoTest(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        protected void onWindowVisibilityChanged(int visibility) {
            if (visibility == View.VISIBLE) { 
                super.onWindowVisibilityChanged(visibility);
            }
        }
    }
    

提交回复
热议问题