From af577fef0848fe853d1ff960284e9c792f050712 Mon Sep 17 00:00:00 2001 From: Hans-Peter Lehmann Date: Thu, 9 Jul 2026 20:57:16 +0200 Subject: [PATCH] Stop playback when currently playing file gets deleted (#8583) ### Description Stop playback when currently playing file gets deleted Closes #8515 ### Checklist - [x] I have read the contribution guidelines: https://github.com/AntennaPod/AntennaPod/blob/develop/CONTRIBUTING.md#submit-a-pull-request - [x] I have performed a self-review of my code, going through my changes line by line and carefully considering why this line change is necessary - [x] I have run the automated code checks using `./gradlew checkstyle lint` - [x] My code follows the style guidelines of the AntennaPod project: https://antennapod.org/contribute/develop/app/code-style - [x] I have mentioned the corresponding issue and the relevant keyword (e.g., "Closes: #xy") in the description (see https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) - [x] If it is a core feature, I have added automated tests --- .../service/Media3PlaybackService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java index c09b97480..8cbf5446c 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java @@ -22,6 +22,7 @@ import androidx.media3.session.SessionCommand; import androidx.media3.session.SessionResult; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.PlayerErrorEvent; import de.danoeh.antennapod.event.StreamingConfirmationEvent; import de.danoeh.antennapod.event.settings.VolumeAdaptionChangedEvent; @@ -746,6 +747,23 @@ public class Media3PlaybackService extends MediaLibraryService { } } + @Subscribe(threadMode = ThreadMode.MAIN) + @SuppressWarnings("unused") + public void feedItemsUpdated(FeedItemEvent event) { + if (currentPlayable == null || !currentPlayable.localFileAvailable()) { + return; + } + int index = FeedItemEvent.indexOfItemWithId(event.items, currentPlayable.getItemId()); + if (index >= 0 && event.items.get(index).getMedia() != null + && !event.items.get(index).getMedia().localFileAvailable()) { + player.stop(); + player.clearMediaItems(); + currentPlayable = null; + PlaybackPreferences.writeNoMediaPlaying(); + EventBus.getDefault().post(new PlayerStatusEvent()); + } + } + private void initLoudnessEnhancer(int audioSessionId) { if (!VolumeAdaptionSetting.isBoostSupported()) { return;