diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 8f1ef9a7e..3ea65d2f2 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -217,8 +217,8 @@ dependencies { implementation("androidx.documentfile:documentfile:1.1.0") implementation("androidx.activity:activity-ktx:1.13.0") implementation("com.google.android.gms:play-services-cast-framework:23.0.0") - // Same version video_player_android bundles, so the APK keeps one copy. - implementation("androidx.media3:media3-exoplayer:1.9.2") + // The root build pins every Media3 module, video_player_android's too. + implementation("androidx.media3:media3-exoplayer:${rootProject.extra["media3Version"]}") // NativeDownloadFinalizer imports FFmpegKit APIs directly. The Flutter // plugin owns the runtime AAR; compileOnly avoids packaging it twice here. compileOnly("com.antonkarpenko:ffmpeg-kit-audio:2.2.3") diff --git a/android/app/src/main/kotlin/com/zarz/mornye/Media3Player.kt b/android/app/src/main/kotlin/com/zarz/mornye/Media3Player.kt index 54a844e83..98cc73483 100644 --- a/android/app/src/main/kotlin/com/zarz/mornye/Media3Player.kt +++ b/android/app/src/main/kotlin/com/zarz/mornye/Media3Player.kt @@ -30,7 +30,7 @@ import io.flutter.plugin.common.MethodChannel * * High resolution: float output is on, and speed goes through the platform * `AudioTrack.setPlaybackParams` (audio output playback parameters). In - * media3 1.9.2 `DefaultAudioSink` sends 24/32-bit PCM to a float + * media3 1.11.1 `DefaultAudioSink` sends 24/32-bit PCM to a float * `AudioTrack` only with float output enabled; otherwise the decoder is asked * for 16-bit PCM and the low bits are lost. With float output its audio * processor chain (Sonic) is skipped for that PCM, so Sonic speed changes @@ -53,14 +53,14 @@ internal fun media3AudioRenderers(context: Context) = RenderersFactory { handler /** * The fastest speed the `AudioTrack` buffer is sized for. With platform - * playback parameters media3 1.9.2 multiplies its PCM buffer (four times - * the platform minimum, kept within 250 to 750 ms) by 8, the fastest - * `AudioTrack` speed, so it still holds that much time at 8x. That makes - * about 3 s at 1x. Once a song's end is in the buffer the track is told to - * play out, so a song queued later than that opens a new track at the - * handoff, and a short song before a queued one waits on the buffer. The app - * changes speed by at most 1.2x (AutoMix), so sizing for 2x keeps at least - * the 1x buffer's time up to 2x at a quarter of the size. Volume + * playback parameters media3 1.11.1 multiplies its PCM buffer (a fixed + * 500 ms) by 8, the fastest `AudioTrack` speed, so it still holds that much + * time at 8x. That makes 4 s at 1x. Once a song's end is in the buffer the + * track is told to play out, so a song queued later than that opens a new + * track at the handoff, and a short song before a queued one waits on the + * buffer. The app changes speed by at most 1.2x (AutoMix), so sizing for 2x + * keeps at least the 1x buffer's time up to 2x at a quarter of the size: 1 s + * at 1x. Volume * (`AudioTrack.setVolume`), speed and the session equalizer act after this * buffer, so its size does not delay them. */ diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 638a039c0..6ce8c6bee 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -5,6 +5,20 @@ allprojects { } } +// Media3 modules must all be one version. The app's playback engine and +// video_player_android (exoplayer plus its HLS, DASH, RTSP and +// SmoothStreaming modules) each ask for their own, so pin the whole group. +extra["media3Version"] = "1.11.1" +subprojects { + configurations.configureEach { + resolutionStrategy.eachDependency { + if (requested.group == "androidx.media3") { + useVersion(rootProject.extra["media3Version"] as String) + } + } + } +} + subprojects { afterEvaluate { if (project.hasProperty("android")) {