How to use wake lock for android media planet?

I am trying to play a playlist with an Android media player. When one track ends; I stop the media player and start it again with a new one. Each time I start the player, I set the track lock using this line;

mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);

For testing; I launch the player and lock the phone screen. After a few tracks; the player stops and cannot move to another track. When this happens, I wait another couple of minutes. Then, when I open the screen of my phone; the player starts immediately.

Is there any possibility that the media player is somehow releasing wakelock? Maybe between the transition of a track to a playlist when it stops? Is MediaPlayer.setWakeMode used correctly when working with playlists? Or should I use the "PowerManager" class directive?

This problem takes too much time to test. thanks in advance.

+5
source share

All Articles