I need to use soundPool
in my app.
The problem is that the sound is only played the first time I launch the app on the emulator. Then I have to uninstall the app to test again.
The boo.mp3 file is 213Ko What I am missing? any idea most welcome.
private fun playThatSound(sound: String) {
var soundPool: SoundPool? = null
var soundId: Int = 0
soundPool = SoundPool(6, AudioManager.STREAM_MUSIC, 0)
when(sound) {
"boo" -> {
soundPool.load(baseContext, R.raw.boo, 1)
soundId = R.raw.boo
}
}
soundPool.play(soundId, 1F, 1F, 0, 0, 1F)
}
I call it like that:
playThatSound("boo")
The sound is only played the first time when I called it, then I have to clear the emulator data or turn my Samsung A50 OFF and ON again before reinstalling the app.
The boo.mp3 file is 213Ko What I am missing? any idea most welcome.