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.
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
maxStreamAnd, of course, something depend on your code, for example, if you do like that:
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 🙂