Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
namespace "com.simform.audio_waveforms"
}

compileSdk 34
compileSdk 36

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<String, Any?> = HashMap()
when (finishMode) {
FinishMode.Stop -> {
Expand Down
8 changes: 8 additions & 0 deletions doc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down