Пытаюсь остановить воспроизведение Soundpool с помощью stop, но звук воспроизводится дальше. Что делать?
protected void loadSounds(){
soundID_shot = soundPool.load(this, R.raw.auido,1);
}
protected void createSoundPool(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
attributesBuilder = new AudioAttributes.Builder();
attributesBuilder.setUsage(AudioAttributes.USAGE_GAME);
attributesBuilder.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION);
attributes = attributesBuilder.build();
soundPoolBuilder = new SoundPool.Builder();
soundPoolBuilder.setAudioAttributes(attributes);
soundPool = soundPoolBuilder.build();
}else {
soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
}
}
button1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int eventAction = event.getAction();
if (eventAction == MotionEvent.ACTION_UP) {
button1.setBackgroundResource(R.drawable.earthquake_anim1);
soundPool.stop(soundID_shot);
}
if (eventAction == MotionEvent.ACTION_DOWN) {
button1.setBackgroundResource(R.drawable.earthquake_anim2);
soundPool.play(soundID_shot,1,1,0,0,1);
}
return true;
}
});
Сборка персонального компьютера от Artline: умный выбор для современных пользователей