views:

20

answers:

1

I have an Android (2.2) project in Eclipse (Helios). I want to add an MP3 file to the project so that the MP3 file is deployed to the device along with the application.

I then would like to open the file as a File object, which means I'd need to know the full path (?) to the file on the device, but I don't know how paths are specified in Android.

+1  A: 

Apparently there is a bug in Froyo that prevents WAV playback.
Audio files should be placed in the "res/raw" directory of your project. Then use the id to play it (or attempt to play it)

MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);
mp.start();

Info: http://developer.android.com/guide/topics/media/index.html
Example (mp3): http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-i

Mondain
They may have fixed it, but I mainly need to figure out how to add file resources to my app.
MusiGenesis
Related http://code.google.com/p/android/issues/detail?id=4875
Mondain
NO MORE WAV! NO MORE WAV! :)
MusiGenesis
Ah you switched to mp3.. nice choice
Mondain
Your code worked with a WAV file, so apparently they fixed whatever the problem was.
MusiGenesis