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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:47:13+00:00 2026-05-30T21:47:13+00:00

I am developing an app where i want to play two mp3 files simultaneously

  • 0

I am developing an app where i want to play two mp3 files simultaneously one as background music and want to control the sound of each player separately. The file size is 5 mb each

i have done with main audio file but when i try to play second file with it it throws error

  SoundManager mSoundManager = new SoundManager();
        mSoundManager.initSounds(getBaseContext());

        mSoundManager.addSound(1,R.raw.music);
        mSoundManager.addSound(2,R.raw.mentalafslapning);
        mSoundManager.playSound(1);
        mSoundManager.playSound(2);


    }
class SoundManager
{
    private  SoundPool mSoundPool; 
     private  HashMap<Integer, Integer> mSoundPoolMap; 
     private  AudioManager  mAudioManager;
     private  Context mContext;
     private  Vector<Integer> mAvailibleSounds = new Vector<Integer>();
     private  Vector<Integer> mKillSoundQueue = new Vector<Integer>();
     private  Handler mHandler = new Handler();

     public SoundManager(){}

     public void initSounds(Context theContext) { 
       mContext = theContext;
          mSoundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0); 
          mSoundPoolMap = new HashMap<Integer, Integer>(); 
          mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);       
     } 

     public void addSound(int Index, int SoundID)
     {
      mAvailibleSounds.add(Index);
      mSoundPoolMap.put(Index, mSoundPool.load(mContext, SoundID, 1));

     }

     public void playSound(int index) { 
      // dont have a sound for this obj, return.
      if(mAvailibleSounds.contains(index)){

          int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 
          int soundId = mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f);

          mKillSoundQueue.add(soundId);

          // schedule the current sound to stop after set milliseconds
          mHandler.postDelayed(new Runnable() {
           public void run() {
            if(!mKillSoundQueue.isEmpty()){
             mSoundPool.stop(mKillSoundQueue.firstElement());
            }
              }
          }, 3000);
      }
     }    

IS it possible to play both the files at same time and control the volume of each separately?

  • 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-30T21:47:14+00:00Added an answer on May 30, 2026 at 9:47 pm

    All the comments I have read suggest that SoundPool is not applicable to playing long sounds.
    You have to get a bit suspicious of OS quality when every one gets an error message with the exact same parameters, else it is an amazing coincidence.

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

Sidebar

Related Questions

I am developing an entertainment app in android. I want to play background music,
I am developing an iphone game app. I want to play different audios(*.mp3) in
i'm new in Objective C, i'm developing an app that play sound on touch
I am developing a web-app where I want to provide a download link to
I'm developing a Mac OS X Cocoa app and want to use several .dylib
I have a command line Ruby app I'm developing and I want to allow
I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to
I have a winforms (VB 2008) based app that I'm developing and I want
When developing an app that will listen on a TCP/IP port, how should one
When one wants to publish his app on the Play Store (previously known as

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.