Quick note: I'm using the SoundPool class
http://developer.android.com/reference/android/media/SoundPool.html
What I have here is a simple button that plays a looped sound while it's pressed. It works great. However, sounds.autoPause();
wasn't introduced until API 8 and I really need something that is cupcake compatible (API 3) So i was going through the dev reference site filtered by API 3 stuff and i saw pause so i figured i'd try sounds.pause(sound);
but it doesn't stop the sound when i release it.(Maybe i'm just using it wrong?) Does anyone know of a cupcake friendly way to stop this sound? thanks!
edit: also tried sounds.stop(sound);
that didn't work either.
The Code:
My onCreate:
sounds = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
sound = sounds.load(this.getApplicationContext(), R.raw.red_long_one, 1);
Then here's my touch event
@Override public boolean onTouch(View arg0, MotionEvent event) {
switch (event.getAction() ) {
case MotionEvent.ACTION_DOWN:
System.out.println("touch");
sounds.play(sound, 1, 1, 1, -1, 1);
break;
case MotionEvent.ACTION_UP:
System.out.println("up");
//autoPause does not work on anything lower than sdk8
sounds.autoPause();
break;
}
return false;
}
I don't understand why sounds.stop(sound);
doesn't seem to work, that seems to but what any article i read recommends to do
I think it's worth noting that if i use sounds.stop(sound);
it works ONE time then after that it won't stop after i let go. but the first press and release it works as intended.
Now, I know on the andoird site it says streamID and not soundID but i have no idea how to get the streamID