Add Media3 session and library session callbacks#5144
Conversation
Generated by 🚫 Danger |
There was a problem hiding this comment.
Pull request overview
This PR advances the Media3 migration by introducing Media3 session callback implementations for session connection/custom commands and for library browsing/search, along with unit tests validating key behaviors.
Changes:
- Added
Media3SessionCallbackto handle MediaSession connection capabilities, custom commands, rating, media-button events, and play-from-search/mediaId behavior. - Added
Media3LibrarySessionCallbackto provide browse tree + search APIs and delegate session-level operations toMedia3SessionCallback. - Added Robolectric tests for both callbacks, and exposed legacy custom-action constants for reuse in the new callbacks/tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3SessionCallback.kt | New Media3 MediaSession.Callback implementing connection commands, custom commands, media button handling, etc. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3LibrarySessionCallback.kt | New Media3 MediaLibrarySession.Callback for browse/search and delegation to the session callback. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionManager.kt | Makes app custom-action constants internal so they can be reused by Media3 code/tests. |
| modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3SessionCallbackTest.kt | Adds tests for connection commands, custom commands, rating, and media-button behavior. |
| modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3LibrarySessionCallbackTest.kt | Adds tests for library root/children/search, connection validation, and playback resumption. |
You can also share your feedback on Copilot code review. Take the survey.
| import androidx.media3.session.MediaLibraryService | ||
| import androidx.media3.session.MediaSession | ||
| import androidx.media3.session.SessionCommand | ||
| import au.com.shiftyjelly.pocketcasts.models.entity.BaseEpisode |
There was a problem hiding this comment.
Fixed — removed unused BaseEpisode import.
6d0e4b8 to
1ad148d
Compare
d85dfab to
4841ed3
Compare
|
Version |
1ad148d to
3ef0f55
Compare
3ef0f55 to
952392b
Compare
4841ed3 to
497b54c
Compare
There was a problem hiding this comment.
Pull request overview
Adds the initial Media3 Session / LibrarySession callback implementations (and accompanying unit tests) as part of the Media3 migration, providing command routing, media-button handling, and browse/search plumbing.
Changes:
- Introduce
Media3SessionCallbackto handle connection capabilities, custom commands, rating, play-from-id/search, and media-button events. - Introduce
Media3LibrarySessionCallbackto provide browse/search and delegate session-level behavior toMedia3SessionCallback. - Add Robolectric tests for both callbacks; expose legacy
APP_ACTION_*constants for reuse.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3SessionCallbackTest.kt | Adds unit coverage for Media3 session connect/custom commands/rating/media-button handling. |
| modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3LibrarySessionCallbackTest.kt | Adds unit coverage for library root/children/search, connection validation, and delegation. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionManager.kt | Makes APP_ACTION_* constants internal so Media3 callbacks/tests can reuse them. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3SessionCallback.kt | New Media3 MediaSession.Callback implementation. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/Media3LibrarySessionCallback.kt | New Media3 MediaLibrarySession.Callback implementation with browse/search + delegation. |
952392b to
d19918c
Compare
- Only set userRating for PodcastEpisode (UserEpisode doesn't support starring) - Use PLAY_WHEN_READY_CHANGE_REASON_REMOTE for cast state updates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d19918c to
fc7b947
Compare
f992988 to
376454a
Compare
376454a to
8eceb80
Compare
- Simplify seekTo overloads (remove redundant if/else) - Prevent duplicate listeners in internal list - Treat blank artwork URLs as null
This test references methods (loadSuggestedChildren, loadRecentChildren) and fields (upNextQueue, podcastManager, episodeManager, playlistManager) that were extracted from PlaybackService into BrowseTreeProvider. The same functionality is now covered by BrowseTreeProviderTest. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6430eb6 to
f2c3455
Compare
Return SessionError.ERROR_NOT_SUPPORTED instead of RESULT_SUCCESS when the provided Rating is not a HeartRating. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8eceb80 to
9c15b07
Compare
Description
This PR is the 4th step of media3 migration.
This adds key components vital to the session ecosystem.
Media3SessionCallbacktakes care of connecting and disconnecting to the service, setting capabilities and forwarding custom commands to the underlyign player.Media3LibrarySessionCallbackprovides browse and search functionality, and delegates session-related calls to the session callback.Testing Instructions
Just review the code pls
Checklist
./gradlew spotlessApplyto automatically apply formatting/linting)modules/services/localization/src/main/res/values/strings.xml