mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-02-01 11:19:31 +00:00
Alert user when player can't open a voice recording
This commit is contained in:
parent
2e8b258b90
commit
3a2757d962
3 changed files with 22 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -479,6 +479,7 @@
|
|||
<string name="conversation_dialog_open_or_export_file_message">&appName; ne peut ouvrir ce fichier.\n\nVoulez-vous l\'ouvrir dans une autre app (si possible), ou le sauvegarder sur votre appareil ?</string>
|
||||
<string name="conversation_dialog_open_file_label">Ouvrir le fichier</string>
|
||||
<string name="conversation_dialog_export_file_label">Sauvegarder le fichier</string>
|
||||
<string name="conversation_failed_to_play_voice_recording_message">Impossible de lire le message vocal !</string>
|
||||
<string name="conversation_message_deleted_toast">Le message a été supprimé</string>
|
||||
<string name="conversation_failed_to_create_toast">Échec de la création de la conversation !</string>
|
||||
<string name="conversation_invalid_participant_due_to_security_mode_toast">Pour des raisons de sécurité, la création d\'une conversation avec un participant d\'un domaine tiers est désactivé.</string>
|
||||
|
|
|
|||
|
|
@ -515,6 +515,7 @@
|
|||
<string name="conversation_dialog_open_or_export_file_message">&appName; can\'t open this file.\n\nDo you want to open it in another app (if possible), or export it on your device?</string>
|
||||
<string name="conversation_dialog_open_file_label">Open file</string>
|
||||
<string name="conversation_dialog_export_file_label">Export file</string>
|
||||
<string name="conversation_failed_to_play_voice_recording_message">Voice recording cannot be played!</string>
|
||||
<string name="conversation_message_deleted_toast">Message has been deleted</string>
|
||||
<string name="conversation_failed_to_create_toast">Failed to create conversation!</string>
|
||||
<string name="conversation_invalid_participant_due_to_security_mode_toast">Can\'t create conversation with a participant not on the same domain due to security restrictions!</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue