VideoView onResume loses buffered portion of the video

后端 未结 10 536
北恋
北恋 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:38

    I found a solution fix it:

    VideoView videoView;
    MediaPlayer mp;
    
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    this.mp = mp;
                }
            });
    
    public void pause(){
        //NOT videoview.pause();
        if (mp != null){
           mp.pause();
        }
    }
    
    public void resume(){
        //NOT videoview.resume();
        if (mp != null){
           mp.start();
        }   
    }
    

    It work for me, i sure it help you

提交回复
热议问题