Skip to content

build: ⬆️ Migrate Android playback from ExoPlayer 2 to Media3 - #510

Open
victorrss wants to merge 5 commits into
SimformSolutionsPvtLtd:mainfrom
victorrss:build.migrate-android-media3
Open

victorrss wants to merge 5 commits into
SimformSolutionsPvtLtd:mainfrom
victorrss:build.migrate-android-media3

Conversation

@victorrss

@victorrss victorrss commented Aug 13, 2026 •

Copy link
Copy Markdown

Description

Standalone ExoPlayer 2 is discontinued. Android playback now uses Media3 ExoPlayer 1.11.0. The Dart PlayerController API is unchanged. Plugin minSdk is aligned to 23 (already documented) and compileSdk is 36 (required by Media3 1.11.0).

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

There are no Android instrumented tests in this repo. Verified with flutter build apk --debug and by running the example app on an Android emulator (local MP3 prepare/play/pause). Gradle no longer resolves com.google.android.exoplayer2.

Android setup docs now require compileSdk 36. The example app compileSdk is updated to match. No Dart API or dartdoc changes.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #509

Replace discontinued ExoPlayer 2.17.1 with Media3 1.11.0 so Android playback stays on a supported library.

Co-authored-by: Cursor <cursoragent@cursor.com>
victorrss and others added 3 commits August 13, 2026 18:18
Host apps must compile against API 36 because Media3 1.11.0 rejects lower compileSdk values.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the changelog on a patch release instead of the unreleased 2.1.0 section.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Media3 on the existing unreleased 2.1.0 heading instead of a 2.0.3 patch.

Co-authored-by: Cursor <cursoragent@cursor.com>

@yash-fadadu-simform yash-fadadu-simform left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for this. The migration itself works: playback behaves the same as on main, and switching to onPlaybackStateChanged is the right replacement for the deprecated callback. But the @OptIn added here fails Android lint, and Media3 1.11.0 forces compileSdk 36 and minSdk 23 on every app that uses the plugin, which the PR marks as not breaking. So I'm requesting changes.

Tested on a Pixel 7 emulator (API 36) with a scripted check that calls the PlayerController API on main and on this branch, plus Gradle lint on the plugin module:

Case main This PR
Example APK builds ✅ ✅
:audio_waveforms:lintDebug ✅ ❌ UnsafeOptInUsageError at AudioPlayer.kt:14
prepare, max duration (audio1.mp3) ✅ 27167 ms ✅ 27123 ms
play, pause, seekTo(3000), setRate, setVolume ✅ ✅
Completion fires once for FinishMode pause, loop and stop ✅ ✅
Second controller prepares and plays the same file ✅ ✅
Invalid path throws PlatformException ✅ ✅
No com.google.android.exoplayer2 classes in the APK ❌ ✅

I also used the example app UI on this branch: play, pause, seeking by dragging the waveform, and two bubbles playing at once all worked. Not tested: network URLs, a real device, or anything below API 36.

Inline comments:

  • Blocking AudioPlayer.kt: @OptIn resolves to kotlin.OptIn, so the opt-in is ignored and lint fails. Import androidx.annotation.OptIn.
  • Blocking android/build.gradle: Media3 1.11.0 requires compileSdk 36 and minSdk 23 in apps that use the plugin, so this is a breaking change.
  • Minor CHANGELOG.md: use the **BREAKING:** prefix and list what apps need to change.

Could you squash the four commits into one? The changelog section moves to 2.0.3 and back again between them.

Comment thread android/build.gradle Resolved
Comment thread CHANGELOG.md Resolved
Without an import, @OptIn resolved to kotlin.OptIn, which ignores the
UnstableApi marker and fails Android lint with UnsafeOptInUsageError.
Media3 1.11.0 requires compileSdk 36 and minSdk 23 in consuming apps,
so the CHANGELOG entry is now flagged as breaking.
@victorrss

Copy link
Copy Markdown
Author

Thanks @yash-fadadu-simform

@victorrss

Copy link
Copy Markdown
Author

Is there any action you need from me? It seems your commit covers all the points, @yash-fadadu-simform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Android playback from ExoPlayer 2 to Media3

2 participants