【发布时间】:2012-10-21 11:22:50
【问题描述】:
我正在尝试在按下按钮时循环播放声音。
当我按下按钮让事件“MotionEvent.ACTION_DOWN”不会停止运行声音时,我怎么能这样做?我这样做的方式只运行一次。我已经尝试将return语句更改为false,但它不起作用。
setLoop MediaPlayer 选项对我没有帮助,因为我想继续播放新的声音,尽管当前声音没有完成播放。
这是我的代码:
public boolean onClick(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
//here should not stop running the soundPool
soundPool.play(R.raw.sound1, 1, 1, 1, 0, 1);
}
if(event.getAction() == MotionEvent.ACTION_UP){
// stop running the soundpool
}
return true;
}
【问题讨论】:
标签: java android ontouchlistener onclicklistener soundpool