What is the right way to disable MediaController?

What is the correct way to disconnect MediaControllerwith attached MediaPlayer?

You cannot do mediaController.setMediaPlayer(null)- which immediately calls updatePausePlay, which divides zero.

You cannot call mediaPlayer.release(), as MediaController will call MediaPlayer # getCurrentPosition and throw an IllegalStateException after the call release().

+5
source share
1 answer

try the below snippet in that order

mediaController.hide();
mediaPlayer.stop();
mediaPlayer.release();
+4
source

All Articles