From fc51768197388b9d6c16c721dfdb41f7327d177d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 15 May 2017 15:52:13 -0400 Subject: [PATCH] Work around m4a vs. mp4 issue for voice messages in legacy iOS clients. // FREEBIE --- Signal/src/ViewControllers/SignalAttachment.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/SignalAttachment.swift b/Signal/src/ViewControllers/SignalAttachment.swift index 1337423a8..6905853de 100644 --- a/Signal/src/ViewControllers/SignalAttachment.swift +++ b/Signal/src/ViewControllers/SignalAttachment.swift @@ -170,6 +170,16 @@ class SignalAttachment: NSObject { // Returns the MIME type for this attachment or nil if no MIME type // can be identified. var mimeType: String { + if isVoiceMessage { + // Legacy iOS clients don't handle "audio/mp4" files correctly; + // they are written to disk as .mp4 instead of .m4a which breaks + // playback. So we send voice messages as "audio/aac" to work + // around this. + // + // TODO: Remove this Nov. 2016 or after. + return "audio/aac" + } + if let filename = filename { let fileExtension = (filename as NSString).pathExtension if fileExtension.characters.count > 0 { @@ -275,7 +285,7 @@ class SignalAttachment: NSObject { kUTTypePlainText as String, kUTTypeUTF8PlainText as String, kUTTypeUTF16PlainText as String, - kUTTypeURL as String, + kUTTypeURL as String ] }