my problem is a little bit tricky to describe.
I have a separated resources folder in my project (and in the apk-file).
String path = "/resources/instruments/data/bongo/audio/bong1.wav";
I can already use it with
url = StreamHelper.class.getClassLoader().getResource( path );
url.openStream();
but actually I want to load the file into the SoundPool.
I tried it this way:
SoundPool soundPool = new SoundPool( 5, AudioManager.STREAM_MUSIC, 0 );
soundPool.load ( path, 1 );
… but i always get an error information: “error loading /resourc…”
load(String path, int )
On this link I’ve seen that I need the correct path for File
File file = new File( path );
if( file.exists() )
//always false but i thing if it would be true soundPool.load should work too
Now my question: how has the path to be that it works. Or is there any other idea for my problem (p.e. with the AssetManager) ?
Btw. I know that there are special Android ways to get resources like R.id.View … but in my case it would be not easy to handle.
Thanks!
Personally, I don’t see WAV files as ‘resources’ and I’d suggest you put them in the ‘assets’ folder and use AssetManager as you mentioned.
This works for me…
Create a folder structure in your project…
…then copy your bong1.wav file there.
Use the following to load it. NOTE: DO NOT put ‘/’ in front of ‘instruments’ when supplying the path to soundPool.load()…
Use this to play it…