Hello,

I posted this on the AndDev forums as well, and I'm somewhat of a
novice to Java.

I've tried the following code after seeing the snippet at
http://www.anddev.org/using_soundpool_instead_of_mediaplayer-t3115.html,
and I can't seem to get this to work. Here's what I have:

public class OneShotAlarm extends BroadcastReceiver
{
     private SoundPool soundPool;
      private HashMap<Integer, Integer> soundPoolMap;

    @Override
    public void onReceive(Context context, Intent intent)
    {
      soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
         soundPoolMap = new HashMap<Integer, Integer>();
         soundPoolMap.put(1, soundPool.load(context, R.raw.sound1,
1));

        AudioManager mgr = (AudioManager)
context.getSystemService(Context.AUDIO_SERVICE);
        int streamVolume =
mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
        soundPool.play(soundPoolMap.get(1), streamVolume,
streamVolume, 1, 0, 1f);
    }
}


You'll notice I replaced instaces of 'getContext()' with 'Context', as
'getContext()' doesn't seem to be available from where I have this
code.

Here is my LogCat that's being returned, and no sound is being played:
11-08 19:25:23.679: DEBUG/dalvikvm(1822): Trying to load lib /system/
lib/libsoundpool.so 0x0
11-08 19:25:23.759: DEBUG/dalvikvm(1822): Added shared lib /system/lib/
libsoundpool.so 0x0
11-08 19:25:23.819: WARN/SoundPool(1822): sample 1 not READY

Any ideas on this? I've been pulling my hair out all day messing with
MediaPlayer, then I came across SoundPool and it looked like it would
be a great alternative.

Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
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