Ensure the MusicPlayer cleans up properly
This commit is contained in:
parent
824a6b4806
commit
197d529fe6
@ -262,12 +262,14 @@ public class MusicPlayer implements Runnable, MediaPlayer.OnCompletionListener,
|
|||||||
public void release()
|
public void release()
|
||||||
{
|
{
|
||||||
if (mMediaPlayer != null) {
|
if (mMediaPlayer != null) {
|
||||||
pause();
|
if (mMediaPlayer.isPlaying())
|
||||||
|
mMediaPlayer.pause();
|
||||||
mMediaPlayer.release();
|
mMediaPlayer.release();
|
||||||
mMediaPlayer = null;
|
mMediaPlayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mService.unregisterReceiver(mReceiver);
|
mService.unregisterReceiver(mReceiver);
|
||||||
|
mService.stopForegroundCompat(NOTIFICATION_ID);
|
||||||
|
|
||||||
if (mWakeLock != null && mWakeLock.isHeld())
|
if (mWakeLock != null && mWakeLock.isHeld())
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user