user410220
user410220

Reputation: 21

show the MediaController

Is there a way I can have the MediaController show always?

  videoView = (VideoView) findViewById(R.id.videoView);
  String path = "/sdcard/feiyang/video/sfqx.3GP";
  MediaController m = new MediaController(this);
  videoView.setMediaController(m);
  videoView.setVideoPath(path);
  videoView.start();

I'm using m.show(0);, but it doesn't work.

Upvotes: 1

Views: 3486

Answers (2)

Yaohui.W
Yaohui.W

Reputation: 328

handle Back key event:

mController = new MediaController(this) {
    ...

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            ((Activity) mContext).finish();
        }
        return true;
    }
};

Upvotes: 1

Rupert Bates
Rupert Bates

Reputation: 3061

replace the line in your code that creates the MediaController with this:

MediaController controller = new MediaController(this){
    @Override
    public void hide() {
        this.show(0);
    }

    @Override
    public void setMediaPlayer(MediaPlayerControl player) {
        super.setMediaPlayer(player);
        this.show();
    }
};

then call

videoView.setMediaController(controller); 

in the same way you already are, that should do the trick.

Upvotes: 8

Related Questions