What's the right way to shut down a MediaController
with an attached MediaPlayer
?
You can't do mediaController.setMediaPlayer(null)
- that immediately calls updatePausePlay, which dereferences the null.
You can't call mediaPlayer.release()
, since MediaController is going to call MediaPlayer#getCurrentPosition, and that throws an IllegalStateException after release()
has been called.
try the below snippet, in this order
mediaController.hide();
mediaPlayer.stop();
mediaPlayer.release();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With