Simen Fjellstad
Simen Fjellstad

Reputation: 402

Sounds in SoundPool does not load in android

I am having problems loading sounds for my game. Or, rather, some of the sounds. It seems to have no problem loading R.raw.success and R.raw.fail. but none of the notes will be loaded. The following is my load code:

SoundPool soundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 1);  
int[] sounds = new int[6];        
sounds[0] = soundPool.load(getApplicationContext(), R.raw.note_c, 1);  
sounds[1] = soundPool.load(getApplicationContext(), R.raw.note_d, 1);  
sounds[2] = soundPool.load(getApplicationContext(), R.raw.note_e, 1);  
sounds[3] = soundPool.load(getApplicationContext(), R.raw.note_g, 1);  
sounds[4] = soundPool.load(getApplicationContext(), R.raw.note_a, 1);  
sounds[5] = soundPool.load(getApplicationContext(), R.raw.note_ctwo, 1);  
success_sound = soundPool.load(getApplicationContext(), R.raw.success, 1);  
fail_sound = soundPool.load(getApplicationContext(), R.raw.fail, 1);

It does not seem to matter which order i load the files. Only fail and success is loaded without problem. Sound was working for a good while, but during the last patch I'm working on, the sounds stopped loading. Changing name of the files did not resolve this either.

Have already tried extensively "googling" the errors in all ways shapes and forms, to no avail. I get the the following output in LogCat: (The two last lines are the success and fail sounds loading without problem.)

com.example.application E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application E/NdkMediaExtractor: sf error code: -1010
com.example.application E/SoundPool: Unable to load sample
com.example.application I/OMXClient: Using client-side OMX mux.
com.example.application I/OMXClient: Using client-side OMX mux.

When the sound is supposed to be played, I get the following output:
W/SoundPool: sample 1 not READY

Upvotes: 0

Views: 1199

Answers (1)

GregoryK
GregoryK

Reputation: 3091

The problem might be with your assets (audio files)

I had the same issue (E/NdkMediaExtractor: sf error code: -1010) for some of my video files (.mov) on LG G4 device. (No problems on devices like Samsung S7, Huawei P9)

After converting all files with:

for f in *.mov; do ffmpeg -i "$f" -c copy -movflags +faststart "${f%.mov}.mp4"; done

Video files loaded correctly everywhere.

So, my suggestion to you: try to play with your audio files format - converting them to something else might help.

Upvotes: 1

Related Questions