Fix voice recorder start/pause states.

This commit is contained in:
Onuray Sahin 2022-03-03 19:54:13 +03:00
parent 4254f46065
commit 3bd4a4ccd3
2 changed files with 5 additions and 3 deletions

View file

@ -132,9 +132,11 @@ class VoiceMessageHelper @Inject constructor(
}
fun startOrPausePlayback(id: String, file: File) {
stopPlayback()
val playbackState = playbackTracker.getPlaybackState(id)
mediaPlayer?.stop()
stopPlaybackTicker()
stopRecordingAmplitudes()
if (playbackTracker.getPlaybackState(id) is VoiceMessagePlaybackTracker.Listener.State.Playing) {
if (playbackState is VoiceMessagePlaybackTracker.Listener.State.Playing) {
playbackTracker.pausePlayback(id)
} else {
startPlayback(id, file)

View file

@ -115,7 +115,7 @@ class VoiceMessagePlaybackTracker @Inject constructor() {
}
}
fun getPercentage(id: String): Float {
private fun getPercentage(id: String): Float {
return when (val state = states[id]) {
is Listener.State.Playing -> state.percentage
is Listener.State.Paused -> state.percentage