import UIKit
import VideoEditorSDK
class VideoAddOverlaysFromRemoteURLSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
let customOverlay = Overlay(identifier: "imgly_overlay_grain", displayName: "Grain", url: URL(string: "https://img.ly/static/example-assets/imgly_overlay_grain.jpg")!, thumbnailURL: nil, initialBlendMode: .hardLight)
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.overlays.append(customOverlay)
builder.assetCatalog = assetCatalog
}
let videoEditViewController = VideoEditViewController(videoAsset: video, configuration: configuration)
videoEditViewController.delegate = self
videoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(videoEditViewController, animated: true, completion: nil)
}
func videoEditViewControllerShouldStart(_ videoEditViewController: VideoEditViewController, task: VideoEditorTask) -> Bool {
true
}
func videoEditViewControllerDidFinish(_ videoEditViewController: VideoEditViewController, result: VideoEditorResult) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
func videoEditViewControllerDidFail(_ videoEditViewController: VideoEditViewController, error: VideoEditorError) {
print(error.localizedDescription)
presentingViewController?.dismiss(animated: true, completion: nil)
}
func videoEditViewControllerDidCancel(_ videoEditViewController: VideoEditViewController) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
}