Playback was not completed correctly. Might fix issue #366 and #374

This commit is contained in:
daniel oeh 2014-03-19 14:15:59 +01:00
parent b454ab0974
commit dfa10a5989
2 changed files with 15 additions and 1 deletions

View File

@ -530,7 +530,7 @@ public class PlaybackService extends Service {
stopWidgetUpdater();
}
writePlaybackPreferences();
writePlaybackPreferencesNoMediaPlaying();
if (nextMedia != null) {
stream = !media.localFileAvailable();
mediaPlayer.playMediaObject(nextMedia, stream, startWhenPrepared, prepareImmediately);
@ -555,6 +555,19 @@ public class PlaybackService extends Service {
sendNotificationBroadcast(NOTIFICATION_TYPE_SLEEPTIMER_UPDATE, 0);
}
private void writePlaybackPreferencesNoMediaPlaying() {
SharedPreferences.Editor editor = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext()).edit();
editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_MEDIA,
PlaybackPreferences.NO_MEDIA_PLAYING);
editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID,
PlaybackPreferences.NO_MEDIA_PLAYING);
editor.putLong(
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
PlaybackPreferences.NO_MEDIA_PLAYING);
editor.commit();
}
private void writePlaybackPreferences() {
if (AppConfig.DEBUG)

View File

@ -756,6 +756,7 @@ public class PlaybackServiceMediaPlayer {
mediaPlayer.reset();
}
audioManager.abandonAudioFocus(audioFocusChangeListener);
callback.endPlayback(true);
playerLock.unlock();