I wanted to fade the controller for videos and always show it for audio. This worked
mController = new MediaController(this) {
@Override
public void hide() {
if (mType != TYPE_AUDIO) super.hide();
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
mController.hide();
Activity a = (Activity)getContext();
a.finish();
return true;
}
return false;
}
};
In MediaPlayer.onPrepared I added:
if (mType == TYPE_AUDIO) mController.show(0);
This causes the controller to show at the start of audio playback, but not video playback.
The other phone control buttons continue to work as normal.