diff --git a/Example/Example/VideoEditorModule.swift b/Example/Example/VideoEditorModule.swift index 446fcedc..2cdc3f3b 100644 --- a/Example/Example/VideoEditorModule.swift +++ b/Example/Example/VideoEditorModule.swift @@ -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 } diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index b583d906..50cc6b2f 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -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"