jp14
jp14

Reputation: 13

Playing Audio files from SD card

I wanted to load files from the SD card into a SoundPool as well as ringtones. I am able to successfully get the path of the files, and I am able to play them with MediaPlayer. However, I need the functionality of the SoundPool. I have tried SoundPool.load(String, int) but it appears to not load the file. Is it possible to load files from the SD card into a SoundPool, or is there a better way to do this?

Upvotes: 1

Views: 1308

Answers (1)

ᴘᴀɴᴀʏɪᴏᴛɪs
ᴘᴀɴᴀʏɪᴏᴛɪs

Reputation: 7509

You can use android.os.Environment.getExternalStorageDirectory() to get the directory to your sdcard and append the file and extension, you can then use SoundPool withload(String path, int priority), to access your file.

Or while not recommended you can even hardcode your path to "/sdcard/".

If the problem is not with getting the soundfile path then you can take a look at Creating Sound Effects in Android

Upvotes: 1

Related Questions