开发者

show the MediaController

开发者 https://www.devze.com 2023-01-13 21:24 出处:网络
Is there a way I can have the MediaController show always? videoView = (VideoView) findViewById(R.id.videoView);

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);
  开发者_如何学CvideoView.setVideoPath(path);
  videoView.start();

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


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.


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;
    }
};
0

精彩评论

暂无评论...
验证码 换一张
取 消