Ensure the MusicPlayer cleans up properly

This commit is contained in:
Christopher Eby 2010-02-21 16:31:11 -06:00
parent 824a6b4806
commit 197d529fe6

View File

@ -262,12 +262,14 @@ public class MusicPlayer implements Runnable, MediaPlayer.OnCompletionListener,
public void release()
{
if (mMediaPlayer != null) {
pause();
if (mMediaPlayer.isPlaying())
mMediaPlayer.pause();
mMediaPlayer.release();
mMediaPlayer = null;
}
mService.unregisterReceiver(mReceiver);
mService.stopForegroundCompat(NOTIFICATION_ID);
if (mWakeLock != null && mWakeLock.isHeld())
mWakeLock.release();