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:
parent
21499a2d40
commit
8121d1a6de
13 changed files with 102 additions and 41 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue