Show voice message preview player progress (#1675)

* Show voice message preview player progress

* Update screenshots

* Fix test

* Some nits over mediaplayer stuff

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
Co-authored-by: Marco Romano <marcor@element.io>
This commit is contained in:
jonnyandrew 2023-10-27 21:43:52 +01:00 committed by GitHub
parent 21499a2d40
commit 8121d1a6de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 102 additions and 41 deletions

View file

@ -41,7 +41,8 @@ class VoiceMessageComposerPlayer @Inject constructor(
State(
isPlaying = state.isPlaying,
currentPosition = state.currentPosition
currentPosition = state.currentPosition,
duration = state.duration,
)
}.distinctUntilChanged()
@ -82,12 +83,23 @@ class VoiceMessageComposerPlayer @Inject constructor(
* The elapsed time of this player in milliseconds.
*/
val currentPosition: Long,
/**
* The duration of this player in milliseconds.
*/
val duration: Long,
) {
companion object {
val NotPlaying = State(
isPlaying = false,
currentPosition = 0L,
duration = 0L,
)
}
/**
* The progress of this player between 0 and 1.
*/
val progress: Float =
if (duration <= currentPosition) 0f else currentPosition.toFloat() / duration.toFloat()
}
}

View file

@ -185,6 +185,7 @@ class VoiceMessageComposerPresenter @Inject constructor(
is VoiceRecorderState.Finished -> VoiceMessageState.Preview(
isSending = isSending,
isPlaying = isPlaying,
playbackProgress = playerState.progress,
waveform = waveform,
)
else -> VoiceMessageState.Idle