While this thread is rather old, I have a similar issue - while using the soundpool with the correct streamIDs.
There is a looping sound being started, remembering its stream id. But when I try to stop it like this: SoundPool.stop(mId); nothing happens... the sound simply keeps looping. This happens on API3, API4 and API7... The only way to stop the sounds is by releasing the soundpool instance - but this way, I have to reload all pre-cached data again. On Aug 29, 9:16 am, Jason <[email protected]> wrote: > I use the pause() method inSoundPool... implemented since API level 1 > > http://developer.android.com/reference/android/media/SoundPool.html#p...) > > The streamID(int) is obtained when you play the sound: > > http://developer.android.com/reference/android/media/SoundPool.html#p..., > float, float, int, int, float) > > "Returns non-zero streamID if successful, zero if failed" > > Retain this streamID in your reference the sound, then you can pause > it using the pause/resume methods. > > Personally I create a wrapper object (I call a Sound) which exposes > simple methods like play(), pause(),stop() etc and the internals of > streamID etc are handled in this class. That way I can swap between > using theSoundPooland MediaPlayer but still have the same "Sound" > class exposed to the app. > > On Aug 29, 8:32 am, BryBam <[email protected]> wrote: > > > > > Quick note: I'm using theSoundPoolclass > > >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'tstopthe sound when i release it. > > (Maybe i'm just using it wrong?) Does anyone know of a cupcake > > friendly way tostopthis sound? thanks! > > > edit: also tried sounds.stop(sound); that didn't work either. > > > The Code: > > > My onCreate: > > > sounds = newSoundPool(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'tstopafter 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 -- 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

