A
A
Anatoly2015-12-28 16:31:30
Android
Anatoly, 2015-12-28 16:31:30

How to manage a lot of sounds in an android application?

I am learning android, and as a practice I am writing a small quiz program. In general, it is required, depending on the guessed thing, to reproduce a certain sound. In the last application where there were a few sounds 2-5pcs. just using the SoundPool was enough for me, now I need to play a certain sound (depending on the guessed object), there are about 40 of these sounds in total.
Help me figure out how to organize this without an endless loop if the object is like this - sound 1 if the object is like this - sound 2 if .... ? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Prokhorov, 2015-12-29
@TonyWrong

You can do it like this:

int playSoundWithIdObject(int idObject){
switch(idObject){
case 0:
playSound();
break;
case 1:
playSound();
break;
case n:
playSound();
break;
default;
break;
}
}

Very beauty in the code will not induce, but it will be better if ();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question