Reputation: 2465
My list consists of 12 songs and it has to move in an infinite loop when the button is clicked.my mediaplayer is working fine in emulator but it is getting stuck if i press the button continuously for 32 times in htc mobile.
public void onClick(View v)
{
if(count==listlen)
count=-1;
if(count<listlen)
{
count=count+1;
}
loadpitch(concatstr);
}
load pitch has this
try
{
if(sp.isChecked()||sm.isChecked())
{
mp.reset();
mp=MediaPlayer.create(this,resID);
mp.setLooping(true);
}
if(play==true)
{
mp.start();
}
}
where listlen is the length of the pre-defined list loadpitch is function which loads the song sp and sm are toggle buttons!
Upvotes: 0
Views: 151
Reputation: 7605
check this way for ur media player while starting media player onclick
if (mPlayer!=null) {
mPlayer.stop();
mPlayer.release();
}
mPlayer= MediaPlayer.create(YourActivity.this,song);
mPlayer.start();
Upvotes: 2