Fix crash on audio player

This commit is contained in:
Christophe Deschamps 2024-09-17 18:02:50 +02:00
parent 5588de20f0
commit 43ea270cff

View file

@ -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.")
}
}