|
@@ -593,7 +593,7 @@ class ShareViewController: UIViewController, UITableViewDelegate, UITableViewDat
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
return
|
|
- } else if attachment.hasItemConformingToTypeIdentifier(UTType.mpeg4Audio.identifier) || attachment.hasItemConformingToTypeIdentifier(UTType.mp3.identifier) || attachment.hasItemConformingToTypeIdentifier("org.opus-codec.opus") {
|
|
|
|
|
|
+ } else if isSupportedAudioFormat(attachment: attachment) {
|
|
attachment.loadItem(forTypeIdentifier: UTType.data.identifier, options: nil) { (fileItem, error) in
|
|
attachment.loadItem(forTypeIdentifier: UTType.data.identifier, options: nil) { (fileItem, error) in
|
|
if let fileURL = fileItem as? URL {
|
|
if let fileURL = fileItem as? URL {
|
|
self.getExactAudioDuration(url: fileURL) { durationFormatted in
|
|
self.getExactAudioDuration(url: fileURL) { durationFormatted in
|
|
@@ -660,6 +660,31 @@ class ShareViewController: UIViewController, UITableViewDelegate, UITableViewDat
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func isSupportedAudioFormat(attachment: NSItemProvider) -> Bool {
|
|
|
|
+ var supportedAudioTypes: [UTType] = [
|
|
|
|
+ .mpeg4Audio,
|
|
|
|
+ .mp3,
|
|
|
|
+ .aiff,
|
|
|
|
+ .wav,
|
|
|
|
+ .appleProtectedMPEG4Audio
|
|
|
|
+ ]
|
|
|
|
+
|
|
|
|
+ if let flacType = UTType(filenameExtension: "flac") {
|
|
|
|
+ supportedAudioTypes.append(flacType)
|
|
|
|
+ }
|
|
|
|
+ if let oggType = UTType(filenameExtension: "ogg") {
|
|
|
|
+ supportedAudioTypes.append(oggType)
|
|
|
|
+ }
|
|
|
|
+ if let cafType = UTType(filenameExtension: "caf") {
|
|
|
|
+ supportedAudioTypes.append(cafType)
|
|
|
|
+ }
|
|
|
|
+ if let opusType = UTType(filenameExtension: "opus") {
|
|
|
|
+ supportedAudioTypes.append(opusType)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return supportedAudioTypes.contains { attachment.hasItemConformingToTypeIdentifier($0.identifier) }
|
|
|
|
+ }
|
|
|
|
|
|
func getExactFileSize(url: URL) -> Int64 {
|
|
func getExactFileSize(url: URL) -> Int64 {
|
|
do {
|
|
do {
|