androidbuttonmediacontroller

Android MediaController Next Previous Buttons


So, For Android's MediaController I found this "The "previous" and "next" buttons are hidden until setPrevNextListeners() has been called." I'd like to show the next and previous. Can someone help me understand how to set this up?

Thanks


Solution

  • Assuming you are using a VideoView control withing an activity, (let's call it videoView), you will want to attach a MediaController to it. Try the following:

    MediaController mc = new MediaController(this);
    mc.setPrevNextListeners(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        //Handle next click here
      }
    }, new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        //Handle previous click here
      }
    });
    videoView.setMediaController(mc);
    

    This should do the trick.