diff --git a/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt b/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt
index a17b480e5..96f91e3ef 100644
--- a/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt
+++ b/app/src/main/java/org/linphone/ui/main/chat/model/MessageModel.kt
@@ -704,12 +704,15 @@ class MessageModel @WorkerThread constructor(
val path = voiceRecordPath
Log.i("$TAG Opening voice record file [$path]")
- voiceRecordPlayer.open(path)
-
- val duration = voiceRecordPlayer.duration
- voiceRecordingDuration.postValue(duration)
- val formattedDuration = SimpleDateFormat("mm:ss", Locale.getDefault()).format(duration) // duration is in ms
- formattedVoiceRecordingDuration.postValue(formattedDuration)
+ if (voiceRecordPlayer.open(path) == 0) {
+ val duration = voiceRecordPlayer.duration
+ voiceRecordingDuration.postValue(duration)
+ val formattedDuration =
+ SimpleDateFormat("mm:ss", Locale.getDefault()).format(duration) // duration is in ms
+ formattedVoiceRecordingDuration.postValue(formattedDuration)
+ } else {
+ Log.e("$TAG Player failed to open file at [$path]")
+ }
}
@WorkerThread
@@ -723,6 +726,17 @@ class MessageModel @WorkerThread constructor(
if (isPlayerClosed()) {
Log.w("$TAG Player closed, let's open it first")
initVoiceRecordPlayer()
+
+ if (voiceRecordPlayer.state == Player.State.Closed) {
+ Log.e("$TAG It seems the player fails to open the file, abort playback")
+ onRedToastToShow?.invoke(
+ Pair(
+ R.string.conversation_failed_to_play_voice_recording_message,
+ R.drawable.warning_circle
+ )
+ )
+ return
+ }
}
val lowMediaVolume = AudioUtils.isMediaVolumeLow(coreContext.context)
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index aca25d215..898d454b3 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -479,6 +479,7 @@
&appName; ne peut ouvrir ce fichier.\n\nVoulez-vous l\'ouvrir dans une autre app (si possible), ou le sauvegarder sur votre appareil ?
Ouvrir le fichier
Sauvegarder le fichier
+ Impossible de lire le message vocal !
Le message a été supprimé
Échec de la création de la conversation !
Pour des raisons de sécurité, la création d\'une conversation avec un participant d\'un domaine tiers est désactivé.
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4dd68da65..aba42b1f8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -515,6 +515,7 @@
&appName; can\'t open this file.\n\nDo you want to open it in another app (if possible), or export it on your device?
Open file
Export file
+ Voice recording cannot be played!
Message has been deleted
Failed to create conversation!
Can\'t create conversation with a participant not on the same domain due to security restrictions!