Остановка Soundpool

266
17 мая 2017, 06:36

Пытаюсь остановить воспроизведение 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;
        }
    });
READ ALSO
Помогите создать DialogFragment с помощью View

Помогите создать DialogFragment с помощью View

Всем привет! Пытаюсь создать AlertDialog через фрагмент, реализованный в отдельном классеХочу использовать специальную view для отображения диалога,...

262
Как удалить строку из JTable?

Как удалить строку из JTable?

Я хочу удалить некоторые строки из JTableКак мне это сделать?

417
Singleton retrofit

Singleton retrofit

Как создать один класс на весь проект и использовать его во всех Presenter`ах

255
Передача параметров через ссылку в Java

Передача параметров через ссылку в Java

Решал задачи абрамяна на JavaДо решал до proc, и вот теперь никак не могу решить proc1

272