Cannot play mp3 in the background with a service

Hello everybody ,
I have a playlist, I wanted it playing in the background with a service. However, I do not understand why it was played 4-5 songs is stop. though service is still running, not killed. I have also used a variety of ways such as: Wifilock, WakeLock, … but still no results. I thought it was stopped due to not wake Wifi / 3G in battery saving mode. I tried to run the examples here (, but the result still same above.
.Hope everybody help please.

The solution: it needs to be written like this: MediaPlayer p = Mediaplayer.create(this, filename) because p.create will call the static method, and it will return a new instance of a MediaPlayer, which is never stored. Then, I called start() on the default-constructed instance, that is why it was not working.

Few steps to follow…

1.First go through the service examples.

2.From this activity start a service ie., whenever this app opened navigate activity to service the activity----> service.

3.In service override onstart().

4.In onstart() create musicplayer function and cal the song you want.

5.And start like this;

6.Now it will run on background