Android back button and MediaController

后端 未结 4 1854
别那么骄傲
别那么骄傲 2020-12-03 03:09

I know how to take control of the back button. I have a VideoView embedded in a FrameLayout. My question is when the video pops up, the video contr

4条回答
  •  醉梦人生
    2020-12-03 03:39

    You can simply write:

    mVideoView.setMediaController(new MediaController(this){
            public boolean dispatchKeyEvent(KeyEvent event)
            {
                if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
                    ((Activity) getContext()).finish();
    
                return super.dispatchKeyEvent(event);
            }
        });
    

    No need to create new class.

提交回复
热议问题