Using the following article as a reference, I am creating an Android app on kotlin.
https://akira-watson.com/android/kotlin/soundpool-play.html
What I want to do is create about 50 buttons and make different sounds from each button in the sound pool.
I think I can write briefly if I can write in a loop sentence, but when I load the sound source,
soundOne=soundPool.load(this, R.raw.one, 1)
Would it be possible to use R.raw.one
in as a variable and substitute the name of the sound source?
Also, button on-click events
button1.setOnClickListener
Can I use button1
in as a variable and turn it into a for statement?
Name the audio file e.g. "sound1.mp3", "sound2.mp3", ... "sound50.mp3", and
Why don't you get the second argument for soundPool.load, as follows?
for (i in 1..50) {
val resourceId = this.resources.getIdentifier("sound$i", "raw", this.packageName)
}
© 2024 OneMinuteCode. All rights reserved.