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 1053051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:11:30+00:00 2026-05-16T17:11:30+00:00

I have a soundpool object and several sounds, but once created I can’t change

  • 0

I have a soundpool object and several sounds, but once created I can’t change the sounds playback in anyway, such as number of loops, volume, stopping, etc.

Declaration code:

public SoundPool sounds;
public HashMap<Integer, Integer> soundmap = new HashMap<Integer, Integer>();
static final public int UFO=3;
static final public int PlayerDeath=3;
static final public int InvaderDeath=2;
static final public int PlayerFire=1;

Sound assignment code:

sounds = new SoundPool(10,AudioManager.STREAM_MUSIC,0);
soundmap.put(PlayerDeath,sounds.load(getContext(), R.raw.explosion, 1));
soundmap.put(InvaderDeath,sounds.load(getContext(), R.raw.invaderkilled, 1));
soundmap.put(PlayerFire,sounds.load(getContext(),R.raw.shoot, 1));
soundmap.put(UFO,sounds.load(getContext(),R.raw.ufo, 1));

Start/stop code:

public void PlayUFOMusic()
{
    sounds.play(soundmap.get(UFO),0.8F,0.8F,1,2000,1);      
}

public void StopUFOMusic()
{
     sounds.stop(soundmap.get(UFO));
}

I know these functions are being called but nothing will cause it change in anyway. I’ve also tried setLoop, setVolume, pause and unload, none of these worked either.

Any ideas?

  • 1 1 Answer
  • 1 View
  • 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-16T17:11:31+00:00Added an answer on May 16, 2026 at 5:11 pm

    Here is the play() syntax:

    public final int  play  (int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate)
    

    So shouldn’t it be:

     sounds.play(soundmap.get(UFO),0.8F,0.8F,1,-1, 1);
    

    to make the sound loop forever?

    Edit: Read the question a bit to fast but if you use this play function, does it loop?

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

Sidebar

Related Questions

Beginner here. I have a class with a SoundPool object in it. I would
I have created a custom class for my Android project called Sounds I want
Have been reading up and checking other questions, but don't understand / can't seem
have written this little class, which generates a UUID every time an object of
I'm using a SoundPool to play sounds for my Android app. All of the
I have a Sound class: package dubpad.brendan; import android.media.SoundPool; public class Sound { SoundPool
I have 16 buttons in my application to play sounds when I click on
Have a photography site that I want to prevent image copying from. How can
Have created a ATL COM project through which I am inserting Menu Items to
I have a problem. When I try to play sound using Soundpool there is

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.