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

  • Home
  • SEARCH
  • 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 7754791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:24:08+00:00 2026-06-01T12:24:08+00:00

I am encountering problems with playing looping sounds using SoundPool and .OGG files. I

  • 0

I am encountering problems with playing looping sounds using SoundPool and .OGG files. I have this HashMap set up for finding a sound associated to a name and playing it/stopping it

    public void playLoopSound(String soundName){

        currentSound = (Integer) soundMap.get(soundName);

        if(currentSound != -1){
            try{
                Logger.log("Playing Loop Sound: " + currentSound);
                loopingSound = soundPool.play(currentSound, 1, 1, 0, -1, 1);
            } catch (Exception e) {
                Logger.log("Sound Playing Error: " + e.getMessage());
            }
        } else {
            Logger.log("Sound Not Found");
        }
    }

    public void stopLoopSound(){
        soundPool.stop(loopingSound);
        loopingSound = 0;
    }

This set up works fine, i start the loop when the character starts walking and stop it when it stops walking.

The sound would however stop playing randomly, usually a minute or so after having been used (being turned on and off)…

Has anyone else encountered similar problems with SoundPool and looped sounds?

  • 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-06-01T12:24:10+00:00Added an answer on June 1, 2026 at 12:24 pm

    Reading the documentation on Soundpool clears up a lot:

    -playing a sound you pass an int referring to the loaded sound. This method (and others starting a sound playing), soundpool.play(int) returns an int referring to the threadID in which the sound now plays.

    -when you want to stop the sound (or the looping sound) you have to use the int of the threadID you just got back when you started playing the sound, NOT the int of the sound itself!

    Within the soundpool class then, you set a private int threadIDInt = mSoundPool.play/setloop/whatever(int soundtobeplayed, int/float volumeleft, int/float volumeright, float speed, int loopornot); [note: the arguments are a bit made up; look ’em up]

    To then stop the sound (or pause, or set it to loop or not) you pass mSoundPool.stop(threadIDINT);

    TLDR: there’s a differnce between the int which denotes your sound and the internal int soundpool uses to denote the stream in which your current sound is playing.

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

Sidebar

Related Questions

I am encountering problems, where when debugging, it's using a port that I dont
I'm using regex snippets to parse smileys into images, and encountering problems with the
I have a straight-up CSS hover, however, I am encountering 2 problems: 1) It
recently I have been encountering problems with exposing events from .NET to COM. I
Greetings, I'm using appcelerator to develop some apps, but I'm encountering some problems. Every
I'm encountering problems in my ASP page. This is a login page which checks
I have a small web app for reporting and im encountering problems with it.
I've been using zc.buildout more and more and I'm encountering problems with some recipes
Every now and then I'm encountering problems with scripts hosted on Github which have
I am encountering problems with using images instead of plain text as links for

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.