import UIKit
import VideoEditorSDK
class VideoAddStickersFromRemoteURLSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
let customSticker = Sticker(imageURL: URL(string: "https://img.ly/static/example-assets/custom_sticker_igor.png")!, thumbnailURL: nil, identifier: "custom_sticker_igor")
let existingSticker = Sticker(imageURL: Bundle.imgly.resourceBundle.url(forResource: "imgly_sticker_emoticons_laugh", withExtension: "png")!, thumbnailURL: nil, identifier: "existing_sticker")
let customStickerCategory = StickerCategory(identifier: "custom_sticker_category", title: "Custom", imageURL: URL(string: "https://img.ly/static/example-assets/custom_sticker_igor.png")!, stickers: [customSticker, existingSticker])
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.stickers.append(customStickerCategory)
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)
}
}