Пытаюсь разобраться с правильной загрузкой звука в Java. Вроде всё получилось, но теперь хочу отследить момент когда все звуки загружаются, но ничего не выходит.
Есть 14 звуков и методом onLoadComplete я пытаюсь поймать конец загрузки.
s1 = strings_sound.load(this, R.raw.e1_1, 1);
s2 = strings_sound.load(this, R.raw.a1_2, 1);
s3 = strings_sound.load(this, R.raw.d2_3, 1);
s4 = strings_sound.load(this, R.raw.g2_4, 1);
s5 = strings_sound.load(this, R.raw.b2_5, 1);
s6 = strings_sound.load(this, R.raw.e3_6, 1);
s_am3 = strings_sound.load(this, R.raw.am_3, 1);
s_am4 = strings_sound.load(this, R.raw.am_4, 1);
s_am5 = strings_sound.load(this, R.raw.am_5, 1);
s_bm2 = strings_sound.load(this, R.raw.bm_2, 1);
s_bm3 = strings_sound.load(this, R.raw.bm_3, 1);
s_bm4 = strings_sound.load(this, R.raw.bm_4, 1);
s_bm5 = strings_sound.load(this, R.raw.bm_5, 1);
s_bm6 = strings_sound.load(this, R.raw.bm_6, 1);
mContext = this;
strings_sound.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
Log.d("MY", "Complete load sampleId = " + sampleId + " status = " + status);
if (status == 0) {
countLoadedSound++;
}
if (countLoadedSound == 14) {
Toast.makeText(mContext, "All files sucessfully loaded", Toast.LENGTH_SHORT).show();
loading_is_ready=1;
}
}
});
По идее должно работать, но почему то в этот метод попадает только 6 звуков. Мой Log:
03-01 23:25:36.117 19464-19464/com.ex.app D/MY: Complete load sampleId = 9 status = 0
03-01 23:25:36.117 19464-19464/com.ex.app D/MY: Complete load sampleId = 10 status = 0
03-01 23:25:36.117 19464-19464/com.ex.app D/MY: Complete load sampleId = 11 status = 0
03-01 23:25:36.117 19464-19464/com.ex.app D/MY: Complete load sampleId = 12 status = 0
03-01 23:25:36.117 19464-19464/com.ex.app D/MY: Complete load sampleId = 13 status = 0
03-01 23:25:36.117 19464-19464/com.ex.app D/MY: Complete load sampleId = 14 status = 0
И id начинается с 9, в чем может быть проблема?