Thanks, SoundPool works almost fine.
Here is my code:

    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);
 }

...
 playSound(SOUND_CLICK);

But there is some issue, when I start my app my sounds somethimes(not
always) may not to play. Just silence.
What's the problem?
Thanks!

On 10 авг, 17:41, Illidane <[email protected]> wrote:
> Thanks for answer!
> When I calling seek(0) before start() nothing changes..
> Thanks for the SoundPool, I'll try it.
>
> On 10 авг, 17:31, Marco Nelissen <[email protected]> wrote:
>
>
>
> > On Mon, Aug 10, 2009 at 5:48 AM, Illidane<[email protected]> wrote:
>
> > > Hello!
> > > I have such code:
> > >        public static MediaPlayer mp_click;
> > >        mp_click = MediaPlayer.create(Context, R.raw.click);
>
> > >            ...
>
> > >            mp_click.start();
>
> > > When my sound played for the first time, it's all fine. But when for
> > > second, third, etc.. it sounds like cutted, just little part of my
> > > "click.wav". If I put there sound in another format like mp3 or ogg -
> > > all just fine.
>
> > Are you just calling start() again, or are you calling seek(0) before that?
>
> > > Or if I write like this:
> > >        mp_click = MediaPlayer.create(CubeTest_Main.Context, R.raw.click);
> > >        mp_click.start();
> > > All if fine too, but this is a bit slow, becouse this sound is playing
> > > very often.
>
> > > If You now how to fix it, pls help me. Thanks.
>
> > You might want to look in to using SoundPool.
--~--~---------~--~----~------------~-------~--~----~
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