Automattic / Automattic/pocket-casts-android

Media3 Migration

Open
#887 1 comment 1 reaction 0 assignees View on GitHub
[Area] Media3 [Type] Tech Debt
Dominant language
Kotlin
Stars
2.8k
Forks
308
Avg merge
1d 13h
Merged PRs (30d)
143

Description

## Tasks/ Checklist

- [x] [Migrate Standalone ExoPlayer libs to Media3 ExoPlayer](https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide#exoplayer) ([PR#886](https://github.com/Automattic/pocket-casts-android/pull/886))
- [x] [Migrate MediaBrowserService to MediaLibraryService](https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide#MediaBrowserService) ([PR#886](https://github.com/Automattic/pocket-casts-android/pull/888))
- [x] Register both (`MediaBrowserService`, `MediaLibraryService`) service interfaces for backward compatibility
- [x] Add `media3-session` dependency
- [x] Change service to inherit from a `MediaLibraryService` instead of `MediaBrowserService`
- [x] Implement the service life-cycle methods
- [x] Implement `MediaLibraryService.MediaLibrarySessionCallback`
- [x] Use `androidx.media3.common.MediaItem` instead of [MediaBrowserCompat.MediaItem](https://developer.android.com/reference/kotlin/android/support/v4/media/MediaBrowserCompat.MediaItem)
- [x] Use `Futures` in contrast to the detachable Result approach of the `MediaBrowserServiceCompat`
- [x] Implement [MediaSession.Callback.onAddMediaItems()](https://github.com/androidx/media/blob/1.0.0/demos/session/src/main/java/androidx/media3/demo/session/PlaybackService.kt#L184)
- [x] Migrate `AutoPlaybackService`

- [ ] Update player for media3
- [x] Migrate local player instantiation to `PlaybackService` ([PR#894](https://github.com/Automattic/pocket-casts-android/pull/894))
- [ ] Migrate switching to cast player
- [x] Set wrapper player class on the media3 session that switches between the local and cast player ([PR#899](https://github.com/Automattic/pocket-casts-android/pull/899))
- [x] Testing ([PR#899](https://github.com/Automattic/pocket-casts-android/pull/899))
- [x] Starting playback on a chromecast from a paused/not-playing state works
- [x] Transferring playback from the phone to the chromecast (and vice-versa) while playback is in progress, and playback continues
- [ ] Cleanup

- [ ] [Control playback in the media session](https://developer.android.com/guide/topics/media/media3/getting-started/playing-in-background#controlling-playback)
- [ ] [Handle UI commands](https://developer.android.com/guide/topics/media/media3/getting-started/playing-in-background#handling-ui)
- [ ] Migrate audio effects
- Globally selected audio effects are used when appropriate
- Podcast-specific audio effects are used when appropriate
- Changes to audio effects during playback take immediate effect
- [ ] Audio focus
- Starts/stops playing appropriately when focus changes. Should check both transient focus changes and non-transient focus changes
- Ducking still works the same as it did before
- [ ] UI commands from Auto, Automotive, Google Maps driving mode should work as before
- [ ] HLS support - [DefaultMediaSourceFactory](https://developer.android.com/guide/topics/media/exoplayer/media-sources) automatically supports HLS, progressive and few other media sources.

- [ ] Up Next Queue
- If the user taps an item in the queue, it starts playing as before
- Transitioning to the next item in the queue occurs as before when an episode finishes

- [ ] [Notification](https://developer.android.com/guide/topics/media/media3/getting-started/playing-in-background#notification) `MediaSessionService` automatically creates a `MediaNotification` that should work in most cases.
- [ ] [Remove PlayerNotificationManager](https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide#PlayerNotificationManager)
- [ ] Migrate custom actions in notifications
- Setting for hiding custom actions should work
- Setting for reordering custom actions should work
- Notification channel should work as expected (disabling/enabling notifications from the channel)
- Button states should update depending on state (star/unstarred, skip forward/backward amount)

- [ ] Support lower API devices
- Test on lower API devices. Sounds like the relevant buckets for purposes of the media notifications are 21 - 28, 29 - 30, and 31 - 32 ([link](https://github.com/androidx/media/issues/158#issuecomment-1231915196)).

- [ ] Test for foreground service exception - [comment](https://rb.gy/nugwh)

Contributor guide

Open the contributing guide

Research direction

Start with the unchecked tasks in this issue and the linked Media3 migration and playback-control guides. Review the completed migration PRs (#886, #888, #894, and #899), then inspect the remaining player, media-session, queue, notification, and lower-API work. Done means all unchecked checklist items pass the listed playback, audio, notification, compatibility, and foreground-service checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
audio-video-rtc, mobile
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.