Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Example/Example/VideoEditorModule.swift
Original file line number Diff line number Diff line change
@@ -10,6 +10,11 @@ import BSImagePicker
import VEExportSDK
import BanubaAudioBrowserSDK

enum BanubaVideoEditorMode: String, CaseIterable {
case video
case photo
}

// Adopting CountdownView to using in BanubaVideoEditorSDK
extension CountdownView: MusicEditorCountdownAnimatableView {}

@@ -19,8 +24,8 @@ class VideoEditorModule {

var isVideoEditorInitialized: Bool { videoEditorSDK != nil }

init(token: String) {
let config = createConfiguration()
init(token: String, videoEditorMode: BanubaVideoEditorMode) {
let config = createConfiguration(videoEditorMode: videoEditorMode)
let externalViewControllerFactory = createExampleExternalViewControllerFactory()

let videoEditorSDK = BanubaVideoEditor(
@@ -72,7 +77,7 @@ class VideoEditorModule {
return progressViewController
}

func createConfiguration() -> VideoEditorConfig {
func createConfiguration(videoEditorMode: BanubaVideoEditorMode) -> VideoEditorConfig {
var config = VideoEditorConfig()

config.setupColorsPalette(
@@ -105,6 +110,14 @@ class VideoEditorModule {
featureConfiguration.isMuteCameraAudioEnabled = true
config.updateFeatureConfiguration(featureConfiguration: featureConfiguration)

switch videoEditorMode {
case .video:
config.recorderConfiguration.captureButtonModes = [.video]
case .photo:
config.recorderConfiguration.captureButtonModes = [.photo]
config.recorderConfiguration.additionalEffectsButtons = config.recorderConfiguration.additionalEffectsButtons.filter { $0.identifier != .sound }
}

return config
}

29 changes: 23 additions & 6 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
musicTrack: musicTrackPreset, // Paste a music track as a track preset at the camera screen to record video with music
animated: true
)
checkLicenseAndOpenVideoEditor(with: launchConfig)
selectVideoEditorModeAndLaunchVE(with: launchConfig)
}

@IBAction func openVideoEditorPiP(_ sender: Any) {
@@ -66,7 +66,7 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
animated: true
)

self.checkLicenseAndOpenVideoEditor(with: launchConfig)
self.checkLicenseAndOpenVideoEditor(with: launchConfig, videoEditorMode: .video)
}
}

@@ -77,7 +77,7 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
animated: true
)

checkLicenseAndOpenVideoEditor(with: launchConfig)
checkLicenseAndOpenVideoEditor(with: launchConfig, videoEditorMode: .video)
}

@IBAction func openVideoEditorTrimmer(_ sender: UIButton) {
@@ -92,7 +92,7 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
animated: true
)

self.checkLicenseAndOpenVideoEditor(with: launchConfig)
self.checkLicenseAndOpenVideoEditor(with: launchConfig, videoEditorMode: .video)
}
}

@@ -104,6 +104,23 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
checkLicenseAndOpenPhotoEditor(with: launchConfig)
}

private func selectVideoEditorModeAndLaunchVE(with launchConfig: VideoEditorLaunchConfig) {
let alertController = UIAlertController(title: "Select Video Editor Mode", message: nil, preferredStyle: .alert)
BanubaVideoEditorMode.allCases.forEach { mode in
alertController.addAction(
UIAlertAction(
title: mode.rawValue,
style: .default,
handler: { [weak self] _ in
self?.checkLicenseAndOpenVideoEditor(with: launchConfig, videoEditorMode: mode)
}
)
)
}

present(alertController, animated: true)
}

@IBAction func openPhotoEditorFromEditor(_ sender: UIButton) {
pickGalleryPhoto() { assets in
guard let asset = assets?.first else {
@@ -183,13 +200,13 @@ class ViewController: UIViewController, BanubaVideoEditorDelegate, BanubaPhotoEd
return musicTrackPreset
}

private func checkLicenseAndOpenVideoEditor(with launchConfig: VideoEditorLaunchConfig) {
private func checkLicenseAndOpenVideoEditor(with launchConfig: VideoEditorLaunchConfig, videoEditorMode: BanubaVideoEditorMode) {
// Deallocate any active instances of both editors to free used resources
// and to prevent "You are trying to create the second instance of the singleton." crash
photoEditorModule = nil
videoEditorModule = nil

videoEditorModule = VideoEditorModule(token: AppDelegate.licenseToken)
videoEditorModule = VideoEditorModule(token: AppDelegate.licenseToken, videoEditorMode: videoEditorMode)

guard let videoEditorSDK = videoEditorModule?.videoEditorSDK else {
invalidTokenMessageLabel.text = "Banuba Video Editor SDK is not initialized: license token is unknown or incorrect.\nPlease check your license token or contact Banuba"