Search code examples
iosswiftapple-live-photos

Swift - create Live Photo from mov and jpg file


I would like to create a live photo from mov and jpg files. I found the LivePhoto library https://github.com/LimitPoint/LivePhoto

When I call generate function, I get an error - " Missing argument for parameter 'completion' in call".

@IBAction func saveLivePhoto(imageUrl: URL, videoUrl: URL){

    LivePhoto.generate(from: imageUrl, videoURL: videoUrl, progress: { percent in }, completion: { livePhoto, resources in

        LivePhoto.saveToLibrary(resources!)
    })
}

What should I do to solve this problem?


Solution

  • You have missed to add completion block parameter in LivePhoto.saveToLibrary function call. Try the code below:

    @IBAction func saveLivePhoto(imageUrl: URL, videoUrl: URL){
    
            LivePhoto.generate(from: imageUrl, videoURL: videoUrl, progress: { percent in }, completion: { livePhoto, resources in
    
                LivePhoto.saveToLibrary(resources!) { (bool) in
                    
                }
            })
        }