diff --git a/CHANGELOG.md b/CHANGELOG.md index 3beb9051..82a42e6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2.1.0 (#unreleased) - Feature [#468](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/pull/468) - Add macOS support +- Chore [#509](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/issues/509) - Migrate Android playback from ExoPlayer 2.17.1 to Media3 1.11.0 ## 2.0.2 diff --git a/android/build.gradle b/android/build.gradle index a8b70a7b..9c57e93b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -29,7 +29,7 @@ android { namespace "com.simform.audio_waveforms" } - compileSdk 34 + compileSdk 36 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -45,11 +45,11 @@ android { } defaultConfig { - minSdkVersion 21 + minSdkVersion 23 } } dependencies { implementation("androidx.multidex:multidex:2.0.1") - implementation "com.google.android.exoplayer:exoplayer:2.17.1" + implementation "androidx.media3:media3-exoplayer:1.11.0" } diff --git a/android/src/main/kotlin/com/simform/audio_waveforms/AudioPlayer.kt b/android/src/main/kotlin/com/simform/audio_waveforms/AudioPlayer.kt index 2948bcd3..7d6f6cb2 100644 --- a/android/src/main/kotlin/com/simform/audio_waveforms/AudioPlayer.kt +++ b/android/src/main/kotlin/com/simform/audio_waveforms/AudioPlayer.kt @@ -4,12 +4,14 @@ import android.content.Context import android.net.Uri import android.os.Handler import android.os.Looper -import com.google.android.exoplayer2.ExoPlayer -import com.google.android.exoplayer2.MediaItem -import com.google.android.exoplayer2.PlaybackException -import com.google.android.exoplayer2.Player +import androidx.media3.common.MediaItem +import androidx.media3.common.PlaybackException +import androidx.media3.common.Player +import androidx.media3.common.util.UnstableApi +import androidx.media3.exoplayer.ExoPlayer import io.flutter.plugin.common.MethodChannel +@OptIn(UnstableApi::class) class AudioPlayer( context: Context, channel: MethodChannel, @@ -50,15 +52,15 @@ class AudioPlayer( result.error(Constants.LOG_TAG, error.message, "Unable to load media source.") } - override fun onPlayerStateChanged(isReady: Boolean, state: Int) { + override fun onPlaybackStateChanged(playbackState: Int) { if (!isPlayerPrepared) { - if (state == Player.STATE_READY) { + if (playbackState == Player.STATE_READY) { player?.volume = volume ?: 1F isPlayerPrepared = true result.success(true) } } - if (state == Player.STATE_ENDED) { + if (playbackState == Player.STATE_ENDED) { val args: MutableMap = HashMap() when (finishMode) { FinishMode.Stop -> { diff --git a/doc/documentation.md b/doc/documentation.md index a130d796..c37c6524 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -144,6 +144,14 @@ Change the minimum Android SDK version to 23 (or higher) in your `android/app/bu minSdkVersion 23 ``` +#### Update compile SDK version + +Android playback uses Media3, which requires compile SDK 36 (or higher): + +```gradle +compileSdk 36 +``` + #### Add permissions Add RECORD_AUDIO permission in `AndroidManifest.xml`: diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index c65ed898..f6190e49 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ android { if (project.android.hasProperty("namespace")) { namespace "com.simform.audio_waveforms_example" } - compileSdk 35 + compileSdk 36 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8