Code example for MediaController

Methods: hide, isShowing, show

0
        if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
            if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
                    keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
                if (mMediaPlayer.isPlaying()) {
                    pause(); 
                    mMediaController.show();
                } else { 
                    start(); 
                    mMediaController.hide();
                } 
                return true; 
            } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
                    && mMediaPlayer.isPlaying()) {
                pause(); 
                mMediaController.show();
            } else { 
                toggleMediaControlsVisiblity(); 
            } 
        } 
 
        return super.onKeyDown(keyCode, event);
    } 
 
    private void toggleMediaControlsVisiblity() { 
		Log.i(TAG, "toggleMediaControlsVisibility");
        if (mMediaController.isShowing()) {
            mMediaController.hide();
        } else { 
            mMediaController.show();
        } 
    } 
 
    public void start() { 
        if (isInPlaybackState()) {