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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:40:10+00:00 2026-05-26T10:40:10+00:00

I load my mp3 via a path into sound pool. For reasons I don’t

  • 0

I load my mp3 via a path into sound pool. For reasons I don’t want to go into I dont want to load via R.raw…

But I get the error:

play(int, float, float, int, int, float) in the type SoundPool is not  applicable for the arguments (Object, float, float, int, int, float)

Is there a way to convert the object to an int?

SoundPool mySoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
HashMap mySoundPoolMap = new HashMap<Integer, Integer>(); 
mySoundPoolMap.put(0,  mySoundPool.load("android.resource://com.App.Notifications/raw/myMP3",1));

float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

mySoundPool.play(mySoundPoolMap.get(0), streamVolume, streamVolume, 1, 0, 1f);
  • 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-26T10:40:10+00:00Added an answer on May 26, 2026 at 10:40 am

    Looking at the SoundPool docs there are a couple of ways to add something to a sound pool:

    1. load(AssetFileDescriptor afd, int priority)
    2. load(Context context, int resId, int priority)
    3. load(String path, int priority)
    4. load(FileDescriptor fd, long offset, long length, int priority)

    Because you don’t want to load a bundled asset you can’t use the either of the first two options. That means you have to use option 3 or 4.

    The best option is to probably download the sound file yourself from the url and then save the file and then add the sound to the SoundPool using a FileDescriptor that points to that file or using the String that contains the path of the file.

    Update: When you add an item to the SoundPool using load an int is returned. This int is a handle to the sound. Then to play the sound you must use that int to tell the SoundPool which sound you want to play:

    For example:

    sp = new SoundPool();
    int handle1 = sp.load(/* add sound 1*/);
    int handle2 = sp.load(/* add sound 1*/);
    
    sp.play(handle2, /*other args*/); // play sound 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In short, I don't want to load an entire wav file into anOpenAL buffer,
I Have this sound chunk but I want to pre load most of this
I load content via jQuery load() but for each time I load a given
I have a function function do_something() { // process $this->load->view('some_view', $data); exec('mv /path/to/folder1/*.mp3 /path/to/folder2/');
Im trying to open an mp3 in soundpool via an id with load, ive
I load a sound like so: sound = [[NSSound alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@alert ofType:@mp3]
I have controls that load mp3 files from other sites, but if it take
Is there a way to load a MP3 file into the soundpool in activity
i'm loading several sound files, and want to error check each load. however, instead
I want to ask for resources on how to load ogg/mp3 files and play

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.