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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:49:53+00:00 2026-05-29T17:49:53+00:00

I have an app which supports shuffling. I am not sure if I should

  • 0

I have an app which supports shuffling. I am not sure if I should create a new Service for every song and destroy the previous one?

Why I am thinking in this way is because currently I shuffle songs in one service with one media player. However, the song should stop somewhere in the middle and next song should start playing – but now I can hear them both although I have only one MediaPlayer. I suspect something is wrong with my fading in and out functions, but it would be easier to manage each track in it’s own service.

  • 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-29T17:49:57+00:00Added an answer on May 29, 2026 at 5:49 pm

    Are you using SoundPool. It looks like this:

    soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);

    Number 5 above mean that has maximum 5 streams can run concurrently. So. you just change 5 to 1.
    And if you use others function. At constructor of its method, you should notice about parameter which name like maxStream

    And, of course, something depend on your code, for example, if you do like that:

    public void onSufftle(){
       String musicfile = Random(...); //your random algorithm to sufftle music
       AssetManager assetManager = getAssets();
       AssetFileDescriptor descriptor = assetManager.openFd(musicfile);                   mediaPlayer.setDataSource(descriptor.getFileDescriptor(),descriptor.getStartOffset(),descriptor.getLength());
       MediaPlayer mediaPlayer = new MediaPlayer();
       mediaPlayer.prepare();
       mediaPlayer.start();    
    

    And of course, if your code like that, each new music is new service because you declare a new MediaPlayer instance.

    So see your code carefully again 🙂

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

Sidebar

Related Questions

I'm developing a web site / web app which supports multiple languages. I have
I have an app on the market which supports widgets. I've made some heavy
I have developed a app which supports FRENCH AND ENGLISH language. App is getting
I wanted to make android app which supports English and Swedish. I have gone
I have Three20 in my app which supports iOS 3.0 and above. When I
In my Universal app which supports IOS4 and later, I have a UINavigationController and
I have a universal app which supports both orientations and all resolutions, so there
I have created app of books which supports pdf and ePub format. In that
I have app in which i have recorded sound files i want that i
I have a app which will download a file from web. The download action

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.