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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.0 (Unreleased)

- Fixed [#350](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/issues/350) - Left most visible wave is clipped in half when recording.
- **BREAKING:** Fixed [#412](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/issues/412) - Calling preparePlayer again does not cancel old waveform extraction.

## 1.3.0

- Fixed [#386](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/pull/386) - On permission denied isRecording flag changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class AudioPlayer(
}
val uri = Uri.parse(path)
val mediaItem = MediaItem.fromUri(uri)
stop()
player?.clearMediaItems()
player = ExoPlayer.Builder(appContext).build()
player?.addMediaItem(mediaItem)
player?.setMediaItem(mediaItem)
player?.prepare()
playerListener = object : Player.Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class AudioWaveformsPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}

private fun initPlayer(playerKey: String) {
if (audioPlayers[playerKey] == null) {
if (!audioPlayers.containsKey(playerKey)) {
val newPlayer = AudioPlayer(
context = applicationContext,
channel = channel,
Expand All @@ -289,6 +289,7 @@ class AudioWaveformsPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.error(Constants.LOG_TAG, "Path can't be null", "")
return
}
extractors[playerKey]?.stop()
extractors[playerKey] = WaveformExtractor(
context = applicationContext,
methodChannel = channel,
Expand All @@ -306,7 +307,6 @@ class AudioWaveformsPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}
)
extractors[playerKey]?.startDecode()
extractors[playerKey]?.stop()
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class WaveformExtractor(
private var progress = 0F
private var currentProgress = 0F

@Volatile
private var started = false
private val finishCount = CountDownLatch(1)
private var inputEof = false
private var sampleRate = 0
Expand Down Expand Up @@ -234,8 +232,6 @@ class WaveformExtractor(
}

fun stop() {
if (!started) return
started = false
decoder?.stop()
decoder?.release()
extractor?.release()
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class AudioPlayer: NSObject, AVAudioPlayerDelegate {
return
}
do {
stopPlayer()
player = nil
player = try AVAudioPlayer(contentsOf: audioUrl!)
do {
if overrideAudioSession {
Expand Down