diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt index a73ce99498..9a18c65a51 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt @@ -718,7 +718,7 @@ class MessageComposerViewModel @AssistedInject constructor( if (isCancelled) { voiceMessageHelper.deleteRecording() } else { - voiceMessageHelper.stopRecording()?.let { audioType -> + voiceMessageHelper.stopRecording(convertForSending = true)?.let { audioType -> if (audioType.duration > 1000) { room.sendMedia(audioType.toContentAttachmentData(isVoiceMessage = true), false, emptySet()) } else { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt index 2886eb7f1b..b7e584b4c0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt @@ -76,13 +76,17 @@ class VoiceMessageHelper @Inject constructor( startRecordingAmplitudes() } - fun stopRecording(): MultiPickerAudioType? { + fun stopRecording(convertForSending: Boolean): MultiPickerAudioType? { tryOrNull("Cannot stop media recording amplitude") { stopRecordingAmplitudes() } val voiceMessageFile = tryOrNull("Cannot stop media recorder!") { voiceRecorder.stopRecord() - voiceRecorder.getVoiceMessageFile() + if (convertForSending) { + voiceRecorder.getVoiceMessageFile() + } else { + voiceRecorder.getCurrentRecord() + } } try { @@ -234,7 +238,7 @@ class VoiceMessageHelper @Inject constructor( } fun stopAllVoiceActions(deleteRecord: Boolean = true): MultiPickerAudioType? { - val audioType = stopRecording() + val audioType = stopRecording(convertForSending = false) stopPlayback() if (deleteRecord) { deleteRecording()