Hm. I think that getStreamVolume() and values expected by play() are
unrelated. getStreamVolume() returns integer value in range
[0,getMaxStreamVolume], while SoundPool.play expects float value in
range [0,1). You should try passing 0.99f to play(), so the resulting
volume of sound will be 0.99f*AudioManager.getStreamVolume().

A note about 0.99f - my last experience with SoundPool was that it
doesn't like 1.0s, it just mutes on that volume, while on 0.99f it
plays loud.


Dmitry

On 3 сен, 01:18, Illidane <[email protected]> wrote:
> Hi all!
> Here is my code:
>     public static final int SOUND_CLICK = 1;
>     public static final int SOUND_DEATH = 2;
>     public static SoundPool soundPool;
>     public static HashMap<Integer, Integer> soundPoolMap;
>     ...
>     soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
>     soundPoolMap = new HashMap<Integer, Integer>();
>     soundPoolMap.put(SOUND_CLICK, soundPool.load(Context, R.raw.click,
> 1));
>     soundPoolMap.put(SOUND_DEATH, soundPool.load(Context, R.raw.death,
> 1));
>     ...
>     public static void playSound(int sound)
>     {
>         AudioManager mgr = (AudioManager)Context.getSystemService
> (Context.AUDIO_SERVICE);
>         int streamVolume = mgr.getStreamVolume
> (AudioManager.STREAM_MUSIC);
>         soundPool.play(soundPoolMap.get(sound), streamVolume,
> streamVolume, 1, 0, 1f);
>     }
>
> After loading this sounds I'm waiting few seconds and than start
> playing them. Usually all is fine, but sometimes one of this sounds
> ( even both ) just disappear.
> What's the problem with it?
> Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to