Skip to content

Add standalone Media3 components#5141

Merged
sztomek merged 4 commits intomainfrom
media3/02-standalone-components
Apr 8, 2026
Merged

Add standalone Media3 components#5141
sztomek merged 4 commits intomainfrom
media3/02-standalone-components

Conversation

@sztomek
Copy link
Copy Markdown
Contributor

@sztomek sztomek commented Mar 17, 2026

Description

2nd step of the media3 migration work.
Created key components that will play important roles in the next phases.
PocketCastForwardingPlayer: Wraps an ExoPlayer and enriches it with episode metadata so that a Media3 MediaSession can read the current media item directly from the player.
MediaSessionActions: Shared action methods used by both the legacy MediaSessionCompat and the new Media3SessionCallback. Reduces duplication across the two callback implementations during the Media3 migration.

Testing Instructions

Just review the code as these components are not yet wired up.

Checklist

  • If this is a user-facing change, I have added an entry in CHANGELOG.md
  • Ensure the linter passes (./gradlew spotlessApply to automatically apply formatting/linting)
  • I have considered whether it makes sense to add tests for my changes
  • All strings that need to be localized are in modules/services/localization/src/main/res/values/strings.xml
  • Any jetpack compose components I added or changed are covered by compose previews
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@sztomek sztomek added this to the 8.10 milestone Mar 17, 2026
@sztomek sztomek requested a review from a team as a code owner March 17, 2026 19:49
@sztomek sztomek requested review from geekygecko and removed request for a team March 17, 2026 19:49
@sztomek sztomek added [Type] Enhancement Improve an existing feature. [Area] Playback Episode playback issue labels Mar 17, 2026
Copilot AI review requested due to automatic review settings March 17, 2026 19:49
@dangermattic
Copy link
Copy Markdown
Collaborator

dangermattic commented Mar 17, 2026

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Media3 migration support in the playback layer by introducing lightweight Player implementations/adapters and extracting shared MediaSession action logic, with Robolectric/unit tests validating behavior.

Changes:

  • Introduce PocketCastsForwardingPlayer to expose episode metadata + command overrides to Media3 Player.
  • Add CastStatePlayer to mirror cast playback state into Media3’s player model.
  • Extract shared MediaSession callback actions into MediaSessionActions and add tests for all new components.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PocketCastsForwardingPlayer.kt New Media3 ForwardingPlayer wrapper exposing Pocket Casts metadata/commands and supporting player swapping.
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/CastStatePlayer.kt New SimpleBasePlayer to represent cast playback state inside a Media3 session.
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActions.kt New shared action helper for legacy + Media3 session callbacks (search/playback actions, analytics).
modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PocketCastsForwardingPlayerTest.kt Robolectric tests for metadata/commands/swapping behavior of PocketCastsForwardingPlayer.
modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/CastStatePlayerTest.kt Robolectric tests validating state mirroring and command delegation for CastStatePlayer.
modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActionsTest.kt Coroutine/Robolectric tests validating MediaSession action behaviors (search, speed, archive/star, analytics).

You can also share your feedback on Copilot code review. Take the survey.

@sztomek sztomek modified the milestones: 8.10, 8.9 Mar 20, 2026
@sztomek sztomek force-pushed the media3/01-foundation branch from 358a86c to 1b9673a Compare March 27, 2026 15:55
@sztomek sztomek force-pushed the media3/02-standalone-components branch from f2c4c68 to 9e355b1 Compare March 27, 2026 15:58
@wpmobilebot wpmobilebot modified the milestones: 8.9, 8.10 Mar 30, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

Version 8.9 has now entered code-freeze, so the milestone of this PR has been updated to 8.10.

Base automatically changed from media3/01-foundation to main March 31, 2026 14:50
Copilot AI review requested due to automatic review settings March 31, 2026 15:24
@sztomek sztomek force-pushed the media3/02-standalone-components branch from 9e355b1 to c4375a8 Compare March 31, 2026 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds standalone Media3 migration components in the repositories playback layer, introducing a forwarding Player that exposes Pocket Casts episode metadata via Media3, plus a shared action handler to reduce duplication between legacy MediaSessionCompat and the new Media3 session callback.

Changes:

  • Introduce PocketCastsForwardingPlayer to wrap a Media3 Player and expose episode/podcast metadata as MediaItem/MediaMetadata.
  • Extract shared media-session actions into MediaSessionActions (play-from-search, speed cycling, archive/star/mark played).
  • Add CastStatePlayer to mirror Pocket Casts cast playback state into Media3’s Player state model, with unit tests for the new components.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PocketCastsForwardingPlayer.kt New Media3 ForwardingPlayer wrapper that owns and publishes enriched MediaMetadata/MediaItem.
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActions.kt New shared action implementation extracted from legacy session callback for Media3 migration.
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/CastStatePlayer.kt New SimpleBasePlayer implementation to surface cast playback state to Media3 session/notifications.
modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PocketCastsForwardingPlayerTest.kt Unit tests validating metadata exposure, command availability, and callback behavior for forwarding player.
modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActionsTest.kt Unit tests covering search playback behavior and key action methods.
modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/CastStatePlayerTest.kt Unit tests for cast state mirroring and command delegation.

@sztomek
Copy link
Copy Markdown
Contributor Author

sztomek commented Mar 31, 2026

@geekygecko i know we discussed that this is a long PR but most of the PR is tests. the key copmonents to review are CastStatePlayer,MediaSessionActions and PocketCastsForwardingPlayer. If you still insist, i can split this in two

@sztomek sztomek force-pushed the media3/02-standalone-components branch from c4375a8 to 9d63c2a Compare March 31, 2026 16:18
- 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>
Copilot AI review requested due to automatic review settings April 1, 2026 20:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

- Simplify seekTo overloads (remove redundant if/else)
- Prevent duplicate listeners in internal list
- Treat blank artwork URLs as null
@sztomek sztomek merged commit ecdff34 into main Apr 8, 2026
18 checks passed
@sztomek sztomek deleted the media3/02-standalone-components branch April 8, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Playback Episode playback issue [Type] Enhancement Improve an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants