Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3319690
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:51:16+00:00 2026-05-17T22:51:16+00:00

Quick note: I’m using the SoundPool class http://developer.android.com/reference/android/media/SoundPool.html What I have here is a

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:51:17+00:00Added an answer on May 17, 2026 at 10:51 pm

    you need to use streamID to stop a sound. streamID is returned by play():

    something like that:

    //record streamid when you play a sound
    streamIDSoundFX=soundPool.play(soundFXPoolMap.get(ctSoundFX), streamVolume, streamVolume, 1, 0, 1f);

    //stop it when you need
    soundPool.stop(streamIDSoundFX);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question. What do you think, I have a few sites that use a
Quick note: Examples from the tutorial Scala for Java Refugees Part 5: Traits and
Quick note So, as I was writing the problem below I found a way
I love the windows 7 sticky note app and need to write a quick
Okay, hopefully this is quick and easy. I have two separate java projects, 'Library'
I'm interested in incorporating the Android UI pattern called "Quick Action". Basically, it's a
Quick add on requirement in our project. A field in our DB to hold
Quick question: Would it be a good or a bad idea to implement my
Quick question: what is the compiler flag to allow g++ to spawn multiple instances
Quick one, but thought I'd ask. Is there a better way of getting the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.