From 7bc412a06e541d1f2bb4bb86b5f1455bbbd681bd Mon Sep 17 00:00:00 2001 From: Hans-Peter Lehmann Date: Fri, 29 May 2026 11:43:30 +0200 Subject: [PATCH] Fix pressing cover to start playing (#8497) ### Description Fix pressing cover to start playing in new playback service Closes #8492 ### 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 --- .../ui/screen/playback/audio/CoverFragment.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/CoverFragment.java index 2bbfdbac1..cb11117e8 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/CoverFragment.java @@ -24,11 +24,13 @@ import androidx.core.content.ContextCompat; import androidx.core.graphics.BlendModeColorFilterCompat; import androidx.core.graphics.BlendModeCompat; import androidx.fragment.app.Fragment; +import androidx.media3.session.MediaController; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.load.resource.bitmap.FitCenter; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.event.PlayerStatusEvent; @@ -77,6 +79,16 @@ public class CoverFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { viewBinding = CoverFragmentBinding.inflate(inflater); viewBinding.imgvCover.setOnClickListener(v -> { + if (BuildConfig.USE_MEDIA3_PLAYBACK_SERVICE) { + if (PlaybackService.isRunning) { + PlaybackController.bindToMedia3Service(getActivity(), MediaController::pause); + } else if (media != null) { + new PlaybackServiceStarter(getContext(), media) + .callEvenIfRunning(true) + .start(); + } + return; + } if (PlaybackService.isRunning && PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING) { getContext().sendBroadcast(MediaButtonStarter.createIntent(getContext(), KeyEvent.KEYCODE_MEDIA_PAUSE));