public class MyCount extends CountDownTimer {
MediaPlayer mp = MediaPlayer.create(this, R.raw.beep1);
public MyCount(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish()
{
mp.star开发者_StackOverflowt();
//Start.this.finish();
}
@Override
public void onTick(long millisUntilFinished)
{
total++;
progre.setProgress(total);
}
}
I want topaly a sound when the progress bar reaches the end (after 30sec) but it's not playing.
Can anybody help me??
I think you need to use the following line:
MediaPlayer mp = MediaPlayer.create(ActivityName.this, R.raw.beep1);
the 'this' in your code is referring to the MyCount class buut you want to use the Activity.
Hmmmmm. It should work because you are playing from a raw resource...maybe the mediaplayer is already being used by something else. Try putting mp.reset() then mp.prepare() before mp.start().
Let me know if that works...
Also JDx answer above may do the trick.
精彩评论