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;
mPlay.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPlayer = new MediaPlayer();
if(play==false)
{
flag++;
if(flag==1)
{
playAudio();
}
else
{
mPlayer.start();
}
mPlay.setText("Pause");
play=true;
}
else if(play==true)
{
mPlayer.pause();
mPlay.setText("Play");
play=false;
}
mPlayer.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
play=false;
flag=0;
}
});