It is released on MediaPlayer.release()
, MediaPlayer.stop()
, and MediaPlayer.reset()
. It's also released onCompletion
and onError
.
Looking through the source for MediaPlayer
here:
It looks like MediaPlayer.stayAwake()
is responsible and this will release the wakelock.
private void stayAwake(boolean awake) {
if (mWakeLock != null) {
if (awake && !mWakeLock.isHeld()) {
mWakeLock.acquire();
} else if (!awake && mWakeLock.isHeld()) {
mWakeLock.release();
}
}
mStayAwake = awake;
updateSurfaceScreenOn();
}
This is a private method but it is called in various states, for example in release()
stayAwake(false)
is called.
Just search through for mWakeLock
and stayAwake(false)
and you'll see. I've also checked as far back as 1.5 and it's the same.