0
我想让Android媒体播放器在此onTouch方法中停止播放声音,但它不会。相反,它开始声音作为最后一个的补充,所以我可以听到它们重叠。如果我让它循环,循环不会停止。即使我不使用isPlaying部分,但插入并检查布尔值,它不起作用。有什么建议?无法让媒体播放器停止
public boolean onTouch(View v, MotionEvent event){
mp = MediaPlayer.create(getBaseContext(), R.raw.tara);
if (event.getAction() == MotionEvent.ACTION_DOWN){
Drawable myIcon = getResources().getDrawable(R.drawable.image1);
getWindow().setBackgroundDrawable(myIcon);
if (mp.isPlaying()){
mp.stop();
}
else {
mp.start();
}
}
else if (event.getAction() == MotionEvent.ACTION_UP){
Drawable myIconup = getResources().getDrawable(R.drawable.image2);
getWindow().setBackgroundDrawable(myIconup);
}
是的是的!这对我来说很愚蠢。我现在在onCreate部分创建它。谢谢! – Vincent 2011-04-09 16:17:11