From 43ea270cff63ad172c73bfeae208bb3ea3aaf7ab Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Tue, 17 Sep 2024 18:02:50 +0200 Subject: [PATCH] Fix crash on audio player --- Classes/Swift/Util/AudioPlayer.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Classes/Swift/Util/AudioPlayer.swift b/Classes/Swift/Util/AudioPlayer.swift index 850b8bd33..5e97e4fce 100644 --- a/Classes/Swift/Util/AudioPlayer.swift +++ b/Classes/Swift/Util/AudioPlayer.swift @@ -55,11 +55,15 @@ class AudioPlayer { NotificationCenter.default.post(name: NSNotification.Name(rawValue: "LinphoneVoiceMessagePlayerEOF"), object: nil, userInfo: userInfo as [AnyHashable : Any]) } CallManager.instance().changeRouteToSpeaker() - do{ - try linphonePlayer?.open(filename: path!) - try linphonePlayer?.start() - }catch{ - Log.e(error.localizedDescription) + if let path = path, FileUtil.fileExists(path: path) { + do{ + try linphonePlayer?.open(filename: path) + try linphonePlayer?.start() + }catch{ + Log.e(error.localizedDescription) + } + } else { + Log.e("[Voice Message] unable to play file, \(path != nil ? path : "nil") does not exist of is empty.") } }