I'm making some fancy app which requires lot of short sounds for its use. Got few questions You might be able to answer.
Is there some restriction to the place I store then in the android project? Currently I put those in bin/res/sounds folder.
Is there a restriction to the format of files and is the .wav ok?
I'm gonna need something to store references to those sounds. I came up with a Dictionary which would consist of a sound name (key) and a path to the file so I could use in such method:
mp = MediaPlayer.create(Test.this, R.raw.mysound);
How should I store R.raw.mysound, it's not a string right?
I apologize If i'm not quite clear about everything, I'm trying my best. Cheers
Usually, you'll store sounds in the raw folder under your res folder (res/raw/mySound.wav). This tells the OS not to mess with it and just copy it over for you. Then you can use the line of code that you posted to load them in.
As for the .wav format that will work fine but it will be really large.
Have a look at what audio formats Android supports: http://developer.android.com/guide/appendix/media-formats.html
The reference (i.e. the R.raw.mySound
) in an int. So you can just map some string to that int if you want but is that really easier than using the R.raw.mySound
id?