Android API : The SoundPool class manages and plays audio resources for applications
Questions tagged [soundpool]
594 questions
14
votes
5 answers
How to play sounds at accurate periods of time across different devices in Android
I'm developing a game in Android and I came across a very annoying, hard-to-find bug. The issue is that when you are using SoundPool to play your sounds, you can actually loop whatever sound you are playing. In this case, the issue is the "running…

Martin Cazares
- 13,637
- 10
- 47
- 54
12
votes
3 answers
Seamless Looping with SoundPool on Android?
I am trying to loop short (20kb), gapless ogg files with the SoundPool class and cannot get consistent results while testing on hardware. It always plays back perfectly using the emulator but when I test on a Nexus 1, or on a Samsumg Galaxy Tab 10.1…

keston
- 121
- 1
- 4
11
votes
1 answer
Play sound with SoundPool
I need to play a short sound in my application. I wrote the following code but I have no sound and strange vibration appeared on my Samsung phone. But in the same time this code works well on my android simulator. My code is:
package…

lubart
- 1,746
- 3
- 27
- 35
11
votes
1 answer
Uncaught exception thrown by finalizer java.lang.IllegalStateException: Binder has been finalized
This code
soundPool.release();
soundPool = null;
sometimes produces this error:
Uncaught exception thrown by finalizer
java.lang.IllegalStateException: Binder has been finalized!
at android.os.BinderProxy.transactNative(Native Method)
at…

activity
- 2,653
- 3
- 20
- 44
11
votes
3 answers
Android SoundPool doesn't play same sound for second time until playing another sound
Here is my Activity:
public class MainActivity extends AppCompatActivity {
private SoundPool soundPool;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
…

Misagh Emamverdi
- 3,654
- 5
- 33
- 57
10
votes
1 answer
Playing default ringtone
I've been trying to use SoundPool to play the default ringtone without success. In the code below
String ringtone = Settings.System.DEFAULT_RINGTONE_URI.getPath();
SoundPool ringPhone = new SoundPool(2, AudioManager.STREAM_RING, 1);
int soundID =…

Kyle Banerjee
- 2,554
- 4
- 22
- 30
9
votes
2 answers
SoundPool "AudioFlinger could not create track, status: -12"
I have an Android app with single button. When the button is clicked, the app starts playing (looping) sound loaded with SoundPool. When the button is clicked again, the sound is stopped, and then started again.
But the problem is that the sound is…

TuomasK
- 502
- 3
- 11
9
votes
1 answer
Android: Recording SoundPool output
I'm allowing the user to push buttons to play sounds via a SoundPool. Is it possible to record whatever the SoundPool is playing so that the user can record a sequence of sounds?

JCL
- 241
- 1
- 2
- 4
9
votes
3 answers
How to stop all sounds in SoundPool?
I am using SoundPool to play sfx sounds in a game on Android. In most cases it works perfectly, except sometimes I need to stop all sounds at once not pause (doesn't matter if they are set to loop or not).
I can't figure out how to stop a sound from…

GameDroids
- 5,584
- 6
- 40
- 59
8
votes
1 answer
Playing multiple sounds using SoundManager
If I play a single sound, it runs fine.
Adding a second sound causes it to crash.
Anyone know what is causing the problem?
private SoundManager mSoundManager;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle…

Jerry
- 81
- 1
- 1
- 2
8
votes
2 answers
Load sound from memory in Android
Is there any way to load a sound samples from memory using SoundPool.load method?
Unfortunatelly, all methods provided in SoundPool are using arguments for real files.
The problem is that I want to load sounds from zip file on SDcard, and extracting…

desertkun
- 1,027
- 10
- 19
8
votes
3 answers
Android audio programming nightmare - soundpool, audiotrack arrghh?
I've built a simple music sequencer Android app that plays multiple audio files.
Originally I was using SoundPool to play mp3 files and it worked perfectly on 2.3.4 with an old HTC Droid Incredible. Then I tested it on a Galaxy Nexus running 4.3 and…

fxfuture
- 1,910
- 3
- 26
- 40
8
votes
1 answer
Android Audio effect on wav file and save it
Requirement
Android open a .wav file in sd card, play it , add some effect (like echo, pitch shift etc), save the file with effect. Simple :(
What I know
I can open and play file using Soundpool or MediaPlayer.
I can give some effect while playing…

Krishnabhadra
- 34,169
- 30
- 118
- 167
8
votes
2 answers
What does "status -12" mean in Android AudioTrack?
When using Android soundpool/audioTrack, I keep getting the following error:
AudioFlinger could not create track, status: -12
Error creating AudioTrack
Can anyone explain what -12 is? Is it the value of some enum from the source code?
I've seen…

Tim
- 35,413
- 11
- 95
- 121
8
votes
1 answer
Android SoundPool.play() sometimes lags
I'm currently facing an issue with my android game. Normally when calling SoundPool.play() the function needs about 0.003 seconds to finish, but sometimes it takes 0.2 seconds which makes my game stutter. where could his anomaly come from?

Andreas Linden
- 12,489
- 7
- 51
- 67