From 7bfb53cc001dcb98a40a3fe327b9d53b4a60a144 Mon Sep 17 00:00:00 2001 From: Tony Tam <149837+tonytamsf@users.noreply.github.com> Date: Sat, 11 Nov 2023 01:55:01 -0800 Subject: [PATCH] Fix sometimes stopping at the end of each episode (#6753) The bug is on this line [#145](https://github.com/AntennaPod/AntennaPod/blob/f7a13065a9c92ba26d3686aeb18269f2313bd0b6/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java#L145) - the call to `PlaybackPreferences.getCurrentlyPlayingFeedMediaId()` returns the episode that was playing and deleted, hence it stops playing the next episode like it is supposed to. Because it's called in a Thread, the next episode already started playing for 1 second or so and then stops The fix will now save into the preference the correct episode that is playing on the PREPARE stage. --- .../antennapod/core/service/playback/PlaybackService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index c41ec93b1..5c8dead81 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -799,6 +799,10 @@ public class PlaybackService extends MediaBrowserServiceCompat { updateNotificationAndMediaSession(newInfo.playable); break; case PREPARED: + if (mediaPlayer.getPSMPInfo().playable != null) { + PlaybackPreferences.writeMediaPlaying(mediaPlayer.getPSMPInfo().playable, + mediaPlayer.getPSMPInfo().playerStatus); + } taskManager.startChapterLoader(newInfo.playable); break; case PAUSED: