The code:
//this is all contained in my MainActivity.

 private SoundPool soundPool;
    private HashMap<Integer, Integer> soundPoolMap;
    public static final int SOUND_CANNON = 1;
    public static final int SOUND_HIT = 2;
    public static final int SOUND_MISS = 3;
    public static final int SOUND_WOUND = 4;
    public static final int SOUND_TAUNT = 5;

    private void initSounds() {

        soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 100);
        soundPoolMap = new HashMap<Integer, Integer>();
        try {
        soundPoolMap.put(SOUND_CANNON, soundPool.load(this,
R.raw.cannon, 1) );
        } catch(Exception e) {
            String s = new String(e.getMessage());

        }

        soundPoolMap.put(SOUND_HIT, soundPool.load(this, R.raw.hit,
1));
        soundPoolMap.put(SOUND_MISS, soundPool.load(this, R.raw.miss,
1));
        soundPoolMap.put(SOUND_WOUND, soundPool.load(this,
R.raw.wound, 1));
        soundPoolMap.put(SOUND_TAUNT, soundPool.load(this,
R.raw.taunt, 1));

        }

The Problem:

soundPool.load fails indicating that the RESOURCE CANNOT BE FOUND.

The oog files cannon, hit, miss, wound, and taunt are in my res/raw
folder (I am using NetBeans with the Android 2.x Emulator, BTW)
As an experiment I have added a line to try to open the same resource
(i.e. via the R.raw.xxx  ID) as an InputStream and that succeeds. So I
am stumped as to why won't load as a soundPool resource.

-- 
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