Add time to voice message composer UI (#1720)

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
jonnyandrew 2023-11-02 12:10:36 +00:00 committed by GitHub
parent b7e6375ac3
commit 3e58e03a10
10 changed files with 50 additions and 23 deletions

View file

@ -100,6 +100,10 @@ class VoiceMessageComposerPlayer @Inject constructor(
* The progress of this player between 0 and 1.
*/
val progress: Float =
if (duration <= currentPosition) 0f else currentPosition.toFloat() / duration.toFloat()
if (duration == 0L)
0f
else
(currentPosition.toFloat() / duration.toFloat())
.coerceAtMost(1f) // Current position may exceed reported duration
}
}

View file

@ -50,6 +50,7 @@ import kotlinx.coroutines.launch
import timber.log.Timber
import java.io.File
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
@SingleIn(RoomScope::class)
class VoiceMessageComposerPresenter @Inject constructor(
@ -191,6 +192,7 @@ class VoiceMessageComposerPresenter @Inject constructor(
isSending = isSending,
isPlaying = isPlaying,
playbackProgress = playerState.progress,
time = playerState.currentPosition.milliseconds,
waveform = waveform,
)
else -> VoiceMessageState.Idle