From a846e417b030e1491c472d50651d58a8f2c15c0e Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 1 Apr 2024 09:55:30 +0200 Subject: [PATCH] Fix playback state not being updated (#7050) --- .../danoeh/antennapod/playback/service/PlaybackService.java | 2 ++ .../antennapod/storage/preferences/PlaybackPreferences.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java index 138c9bc61..dfcb67e51 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java @@ -831,6 +831,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { break; case PAUSED: updateNotificationAndMediaSession(newInfo.playable); + PlaybackPreferences.setCurrentPlayerStatus(PlaybackPreferences.PLAYER_STATUS_PAUSED); if (!isCasting) { stateManager.stopForeground(!UserPreferences.isPersistNotify()); } @@ -841,6 +842,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { //stopService(); break; case PLAYING: + PlaybackPreferences.setCurrentPlayerStatus(PlaybackPreferences.PLAYER_STATUS_PLAYING); saveCurrentPosition(true, null, Playable.INVALID_TIME); recreateMediaSessionIfNeeded(); updateNotificationAndMediaSession(newInfo.playable); diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/PlaybackPreferences.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/PlaybackPreferences.java index d6d260446..9ec20bd2c 100644 --- a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/PlaybackPreferences.java +++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/PlaybackPreferences.java @@ -109,6 +109,10 @@ public abstract class PlaybackPreferences { return prefs.getInt(PREF_CURRENT_PLAYER_STATUS, PLAYER_STATUS_OTHER); } + public static void setCurrentPlayerStatus(int playerStatus) { + prefs.edit().putInt(PREF_CURRENT_PLAYER_STATUS, playerStatus).apply(); + } + public static float getCurrentlyPlayingTemporaryPlaybackSpeed() { return prefs.getFloat(PREF_CURRENTLY_PLAYING_TEMPORARY_PLAYBACK_SPEED, FeedPreferences.SPEED_USE_GLOBAL); }