Only copy imported video when necessary.

Non-mp4's will be moved as part of their conversion.

We only need to move mp4's which were auto-converted

// FREEBIE
This commit is contained in:
Michael Kirk 2017-12-12 12:53:40 -05:00
parent 849388feb7
commit f9d22545b1

View file

@ -516,8 +516,8 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
}
}
// Some host apps (e.g. iOS Photos.app) converts some video formats (e.g. com.apple.quicktime-movie)
// into mp4s as part of the NSItemProvider `loadItem` API.
// Some host apps (e.g. iOS Photos.app) sometimes auto-converts some video formats (e.g. com.apple.quicktime-movie)
// into mp4s as part of the NSItemProvider `loadItem` API. (Some files the Photo's app doesn't auto-convert)
//
// However, when using this url to the converted item, AVFoundation operations such as generating a
// preview image and playing the url in the AVMoviePlayer fails with an unhelpful error: "The operation could not be completed"
@ -537,8 +537,9 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
// Perhaps the AVFoundation APIs require some extra file system permssion we don't have in the
// passed through URL.
private func isVideoNeedingRelocation(itemProvider: NSItemProvider, itemUrl: URL) -> Bool {
guard MIMETypeUtil.isSupportedVideoFile(itemUrl.path) else {
// not a video, isn't affected
guard MIMETypeUtil.utiType(forFileExtension: itemUrl.pathExtension) == kUTTypeMPEG4 as String else {
// Either it's not a video or it was a video which was not auto-converted to mp4.
// Not affected by the issue.
return false
}