From c2555049595316aa04b09f4d87cae77ec3574b95 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 13 Jul 2017 14:31:12 -0400 Subject: [PATCH] Fix copy and paste of voice messages. // FREEBIE --- src/Util/MIMETypeUtil.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Util/MIMETypeUtil.m b/src/Util/MIMETypeUtil.m index a55c68096..5c77a0002 100644 --- a/src/Util/MIMETypeUtil.m +++ b/src/Util/MIMETypeUtil.m @@ -420,6 +420,12 @@ NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype"; + (nullable NSString *)fileExtensionForUTIType:(NSString *)utiType { + // Special-case the "aac" filetype we use for voice messages (for legacy reasons) + // to use a .m4a file extension, not .aac, since AVAudioPlayer can't handle .aac + // properly. Doesn't affect file contents. + if ([utiType isEqualToString:@"public.aac-audio"]) { + return @"m4a"; + } CFStringRef fileExtension = UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)utiType, kUTTagClassFilenameExtension); return (__bridge_transfer NSString *)fileExtension;