简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM