diff --git a/native/expo-modules/comm-expo-package/ios/MediaModule.swift b/native/expo-modules/comm-expo-package/ios/MediaModule.swift --- a/native/expo-modules/comm-expo-package/ios/MediaModule.swift +++ b/native/expo-modules/comm-expo-package/ios/MediaModule.swift @@ -41,6 +41,7 @@ Name("MediaModule") AsyncFunction("getVideoInfo", getVideoInfo) + AsyncFunction("hasMultipleFrames", hasMultipleFrames) } @@ -72,6 +73,16 @@ return videoInfo } + + private func hasMultipleFrames(path: URL) throws -> Bool { + guard let imageSource = CGImageSourceCreateWithURL(path as CFURL, nil) else { + throw FailedToLoadGifException(path) + } + + let count = CGImageSourceGetCount(imageSource) + + return count > 1 + } } // MARK: - Exception definitions @@ -81,3 +92,9 @@ "No video track found in file URI: \(param)" } } + +private class FailedToLoadGifException: GenericException<URL> { + override var reason: String { + "Failed to load gif at URI: \(param)" + } +}