Cliff
Cliff

Reputation: 713

SoundPool issue on Android 11

It seems that soundPool Api is not working correctly on android 11. I hear the sound like slow motion. Have anyone any related issue ?

My code


 private SoundPool soundPool;
 private int wonSound;

...

 soundPool = new SoundPool.Builder().setMaxStreams(1).build();
 wonSound = soundPool.load(this, R.raw.slot_win_1, 1);

...

 soundPool.play(wonSound, 1, 1, 0, 0, 0);


Upvotes: 1

Views: 287

Answers (1)

Thanasis M
Thanasis M

Reputation: 1361

According to the documentation:

https://developer.android.com/reference/android/media/SoundPool#play(int,%20float,%20float,%20int,%20int,%20float)?

SoundPool's function play() takes as its last parameter:

float: playback rate (1.0 = normal playback, range 0.5 to 2.0)

So, playback rates below 1 will sound slower than the original sound. To play your sound in its original playback rate, you should call play() like this:

soundPool.play(wonSound, 1, 1, 0, 0, 1);

Upvotes: 3

Related Questions