Add variable playback speed feature for voice messages
Add playback speed control for voice messages with support for 0.5×, 1×, 1.5×, and 2× playback speeds. The speed button is displayed above the timestamp and cycles through the available speeds when tapped.
This commit is contained in:
parent
a4707a787a
commit
1f0aa23bff
13 changed files with 203 additions and 15 deletions
|
|
@ -10,4 +10,5 @@ package io.element.android.libraries.voiceplayer.api
|
|||
sealed interface VoiceMessageEvents {
|
||||
data object PlayPause : VoiceMessageEvents
|
||||
data class Seek(val percentage: Float) : VoiceMessageEvents
|
||||
data object ChangePlaybackSpeed : VoiceMessageEvents
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ data class VoiceMessageState(
|
|||
val progress: Float,
|
||||
val time: String,
|
||||
val showCursor: Boolean,
|
||||
val playbackSpeed: Float,
|
||||
val eventSink: (event: VoiceMessageEvents) -> Unit,
|
||||
) {
|
||||
enum class Button {
|
||||
|
|
|
|||
|
|
@ -47,10 +47,12 @@ fun aVoiceMessageState(
|
|||
progress: Float = 0f,
|
||||
time: String = "1:00",
|
||||
showCursor: Boolean = false,
|
||||
playbackSpeed: Float = 1.0f,
|
||||
) = VoiceMessageState(
|
||||
button = button,
|
||||
progress = progress,
|
||||
time = time,
|
||||
showCursor = showCursor,
|
||||
playbackSpeed = playbackSpeed,
|
||||
eventSink = {},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue