let urlString = imageGif
DispatchQueue.global(qos: .background).async {
if let url = URL(string: urlString),
let urlData = NSData(contentsOf: url) {
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0];
let filePath="\(documentsPath)/tempFile.mp4"
DispatchQueue.main.async {
urlData.write(toFile: filePath, atomically: true)
let frameCount = 16
let delayTime = Float(0)
let loopCount = 0 // 0 means loop forever
let regift = Regift(sourceFileURL: URL(fileURLWithPath: filePath), frameCount: frameCount, delayTime: delayTime, loopCount: loopCount)
print("Gif saved to \(String(describing: regift.createGif()))")
// if let path = Bundle.main.path(forResource: imageGif, ofType: "gif") {
let url = regift.createGif()
if let data = NSData(contentsOf: url! as URL) {
let gif = FLAnimatedImage(animatedGIFData: data as Data)
self.ivDisplayImageGif.animatedImage = gif
self.progressView.hide(animated: true)
self.loadIntertialAd()
}
//}
}
}
}