we can now support more than just mp4 as audio messages

This commit is contained in:
Mauro Romito
2023-04-12 14:43:52 +02:00
parent 2566e08c53
commit 7e223a8ce9
2 changed files with 15 additions and 6 deletions
@@ -206,11 +206,12 @@ class VoiceMessageAttachmentCacheManager {
}
private func convertFileAtPath(_ path: String?, numberOfSamples: Int, identifier: String, semaphore: DispatchSemaphore) {
guard let filePath = path else {
guard let path else {
return
}
let fileExtension = filePath.hasSuffix(".mp4") ? "mp4" : "m4a"
let filePath = URL(fileURLWithPath: path)
let fileExtension = filePath.hasSupportedAudioExtension ? filePath.pathExtension : "m4a"
let newURL = temporaryFilesFolderURL.appendingPathComponent(identifier).appendingPathExtension(fileExtension)
let conversionCompletion: (Result<Void, VoiceMessageAudioConverterError>) -> Void = { result in
@@ -252,7 +253,7 @@ class VoiceMessageAttachmentCacheManager {
if FileManager.default.fileExists(atPath: newURL.path) {
conversionCompletion(Result.success(()))
} else {
VoiceMessageAudioConverter.convertToMPEG4AAC(sourceURL: URL(fileURLWithPath: filePath), destinationURL: newURL, completion: conversionCompletion)
VoiceMessageAudioConverter.convertToMPEG4AACIfNeeded(sourceURL: filePath, destinationURL: newURL, completion: conversionCompletion)
}
}