I am playing sounds in my application I have the following code
sounds = new HashMap<String, MediaPlayer>();
Then when guys are created on screen they are given a sound.
sounds.put("sounds"+Integer.toString(ncount), MediaPlayer.create(this, R.raw.hit));
I want to remove the MediaPlayer from the hashmap like I do the enemies when they die
sounds.get("sounds"+Integer.toString(ncount)).setOnCompletionListener( new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
sounds.remove("sounds"+Integer.toString(ncount));
}
});
This errors out... how would I reference the sounds hashmap to remove the associated MediaPlayer when sound is complete?
Thanks!