我試圖在按下按鈕時循環聲音。在按下按鈕時循環聲音
我怎麼能這樣做,而我按下按鈕had the事件「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;
}
我我試過兩種方法,只能運行一次 – karse23