import UIKit
import VideoEditorSDK
class AddAudioOverlaysFromAppBundleSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
let elsewhereAudioClipIdentifiers = [
"elsewhere",
"trapped_in_the_upside_down"
]
let otherAudioClipIdentifiers = [
"dance_harder",
"far_from_home"
]
let elsewhereClips = elsewhereAudioClipIdentifiers.map { AudioClip(identifier: $0, audioURL: Bundle.main.url(forResource: $0, withExtension: ".mp3")!) }
let otherClips = otherAudioClipIdentifiers.map { AudioClip(identifier: $0, audioURL: Bundle.main.url(forResource: $0, withExtension: ".mp3")!) }
let elsewhereAudioClipCategory = AudioClipCategory(title: "Elsewhere", imageURL: nil, audioClips: elsewhereClips)
let otherAudioClipCategory = AudioClipCategory(title: "Other", imageURL: nil, audioClips: otherClips)
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.audioClips = [elsewhereAudioClipCategory, otherAudioClipCategory]
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)
}
}