From 72f8a8d74cd85288055a6f5d3210c416db2ccdc1 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Mon, 31 Jul 2023 18:31:23 +0200 Subject: [PATCH] fix audio lenght issue --- .../media/audiomessage/ConversationAudioMessagePlayer.kt | 9 +++++++-- .../messages/ConversationMessagesViewModel.kt | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/media/audiomessage/ConversationAudioMessagePlayer.kt b/app/src/main/kotlin/com/wire/android/media/audiomessage/ConversationAudioMessagePlayer.kt index 30643a5b088..fcd453a9b0f 100644 --- a/app/src/main/kotlin/com/wire/android/media/audiomessage/ConversationAudioMessagePlayer.kt +++ b/app/src/main/kotlin/com/wire/android/media/audiomessage/ConversationAudioMessagePlayer.kt @@ -2,7 +2,10 @@ package com.wire.android.media.audiomessage import android.content.Context import android.media.MediaPlayer +import android.media.MediaPlayer.SEEK_CLOSEST +import android.media.MediaPlayer.SEEK_CLOSEST_SYNC import android.net.Uri +import android.util.Log import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.feature.asset.GetMessageAssetUseCase import com.wire.kalium.logic.feature.asset.MessageAssetResult @@ -110,7 +113,9 @@ class ConversationAudioMessagePlayer audioMessageStateHistory = audioMessageStateHistory.toMutableMap().apply { put( audioMessageStateUpdate.messageId, - currentState.copy(totalTimeInMs = AudioState.TotalTimeInMs.Known(audioMessageStateUpdate.totalTimeInMs)) + currentState.copy( + totalTimeInMs = AudioState.TotalTimeInMs.Known(audioMessageStateUpdate.totalTimeInMs) + ) ) } } @@ -241,7 +246,7 @@ class ConversationAudioMessagePlayer val isAudioMessageCurrentlyPlaying = currentAudioMessageId == messageId if (isAudioMessageCurrentlyPlaying) { - audioMediaPlayer.seekTo(position) + audioMediaPlayer.seekTo(position.toLong(), SEEK_CLOSEST_SYNC) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/ConversationMessagesViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/ConversationMessagesViewModel.kt index 56303ae4349..11843876d1c 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/ConversationMessagesViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/ConversationMessagesViewModel.kt @@ -21,6 +21,7 @@ package com.wire.android.ui.home.conversations.messages import android.content.Context +import android.util.Log import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue