MediaPlayer pause doesnt work in android

后端 未结 1 1710
后悔当初
后悔当初 2021-01-16 16:00

I use the following code to pause the play of an audio file. but it doesn\'t pause. What is wrong with the code. Any suggesstion...

boolean play=false;
int flag=0;
mPl         


        
相关标签:
1条回答
  • 2021-01-16 16:58

    Problem lays here: mPlayer = new MediaPlayer(); You're initializing your player on every click, so what you're trying to pause is a completely new player that cannot be paused, cause it doesn't play. You must initialize the player outside of onClick method.

    0 讨论(0)
提交回复
热议问题