2

I'm trying to play a video with the media controller sets to invisible, so when I override the back key, the video stops and the activity finishes. But, when I press the back button before spending three seconds, I need press the button twice, because the media controller is activated. So, how to hide the media controller when the video starts?

private void playRecording() {
    MediaController mc = new MediaController(this);

    video_view.setMediaController(mc);
    video_view.setVideoPath(output_file_name);

    video_view.start();

    mc.show(0);
    mc.hide();
}

private void stopPlayingRecording() {
    video_view.stopPlayback();
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (is_playing) {
            stopPlayingRecording();
        }

        finish();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
beni
  • 3,019
  • 5
  • 35
  • 55

1 Answers1

0

Once the video is started you can try.

video_view.setMediaController(null);

then if you want to show it again when a user presses on the screen you could implement a ontouchevent that will create one and show it for a few seconds and then set it back to null again

Ron
  • 22,128
  • 31
  • 108
  • 206
krilovich
  • 3,475
  • 1
  • 23
  • 33