diff --git a/example/package.json b/example/package.json index 01039ba..57e072d 100644 --- a/example/package.json +++ b/example/package.json @@ -10,6 +10,7 @@ "build:ios": "cd ios && xcodebuild -workspace VeSdkReactNativeV2Example.xcworkspace -scheme VeSdkReactNativeV2Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO" }, "dependencies": { + "pe-sdk-react-native": "^0.0.1", "react": "18.2.0", "react-native": "0.74.2", "react-native-image-picker": "^7.1.2" diff --git a/example/src/App.tsx b/example/src/App.tsx index be52d0a..ccd916d 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -18,6 +18,8 @@ import VideoEditorPlugin, { WatermarkAlignment, } from 'video-editor-react-native'; +import PhotoEditorPlugin from 'pe-sdk-react-native'; + import { launchImageLibrary } from 'react-native-image-picker'; const LICENSE_TOKEN = SET BANUBA LICENSE TOKEN @@ -30,6 +32,7 @@ export default class App extends Component { // Specify your Config params in the builder below //.setAudioBrowser(...) //... + .setProcessPictureExternally(true) .build(); // Export Data example @@ -58,14 +61,37 @@ export default class App extends Component { }; } - handleVideoExport(response) { + handleVideoExport = async(response) => { let exportedVideoSources = response?.exportedVideoSources let exportedPreview = response?.exportedPreview let exportedMeta = response?.exportedMeta console.log('Export completed successfully: video = ' + exportedVideoSources + '; videoPreview = ' + exportedPreview + "; meta = " + exportedMeta); + + // exportedVideoSource is an empty Array in case of exporting the photo from the Video Editor + + if (Array.isArray(exportedVideoSources) && exportedVideoSources.length === 0) { + + // Open Photo Editor after Video Editor export + await this.openPhotoEditorWithImagePath(response?.exportedPreview) + + } + } + + handlePhotoExport(response) { + let exportedPhotoSource = response?.exportedPhotoSource; + this.setState({ imageUri: `file://${exportedPhotoSource}` }); + console.log('Export completed successfully: photo = ' + imageUri); } + openPhotoEditorWithImagePath = async (photoUri: string) => { + const photoEditor = new PhotoEditorPlugin(); + photoEditor + .openFromEditor(LICENSE_TOKEN, photoUri) + .then((response) => this.handlePhotoExport(response)) + .catch((e) => this.handleSdkError(e)); + }; + handleSdkError(e) { console.log('handle sdk error = ' + e.code); @@ -83,6 +109,8 @@ export default class App extends Component { message = "Missing host Activity to start video editor"; case 'ERR_VIDEO_EXPORT_CANCEL': message = "The user has canceled video editing flow!"; + case 'ERR_PHOTO_EXPORT_CANCEL': + message = 'The user has canceled photo editing flow!'; case 'ERR_INVALID_PARAMS': message = e.message; default: diff --git a/package-lock.json b/package-lock.json index 2efe6a5..6cc6d36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "name": "video-editor-react-native-example", "version": "0.0.1", "dependencies": { + "pe-sdk-react-native": "^0.0.1", "react": "18.2.0", "react-native": "0.74.2", "react-native-image-picker": "^7.1.2" @@ -18679,6 +18680,19 @@ "node": ">=8" } }, + "node_modules/pe-sdk-react-native": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pe-sdk-react-native/-/pe-sdk-react-native-0.0.1.tgz", + "integrity": "sha512-B80H70lTShagZOuVc1M0nkIqN7Kx5sthHt+Ajscb9xo5u6EHlA7Cf6VE82UCh0dvCysheu42vdnlnrsRTpNVFA==", + "license": "MIT", + "workspaces": [ + "example" + ], + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/picocolors": { "version": "1.0.1", "license": "ISC" diff --git a/yarn.lock b/yarn.lock index f0c6aa2..88cc109 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5796,6 +5796,11 @@ path-type@^3.0.0: path-type@^4.0.0: version "4.0.0" +pe-sdk-react-native@^0.0.1: + version "0.0.1" + resolved "https://registry.npmjs.org/pe-sdk-react-native/-/pe-sdk-react-native-0.0.1.tgz" + integrity sha512-B80H70lTShagZOuVc1M0nkIqN7Kx5sthHt+Ajscb9xo5u6EHlA7Cf6VE82UCh0dvCysheu42vdnlnrsRTpNVFA== + picocolors@^1.0.0, picocolors@^1.0.1: version "1.0.1"