Work around m4a vs. mp4 issue for voice messages in legacy iOS clients.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-05-15 15:52:13 -04:00
parent ab94eaed45
commit fc51768197
1 changed files with 11 additions and 1 deletions

View File

@ -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
]
}