diff --git a/App.js b/App.js index 9f75e1c..f5eccca 100644 --- a/App.js +++ b/App.js @@ -6,38 +6,41 @@ import { View, Platform, NativeModules, + TouchableOpacity } from 'react-native'; const {SdkEditorModule} = NativeModules; // Set Banuba license token for Video and Photo Editor SDK const LICENSE_TOKEN = SET LICENSE TOKEN -function initSDK() { - SdkEditorModule.initSDK(LICENSE_TOKEN); +function initVideoEditorSDK() { + SdkEditorModule.initVideoEditorSDK(LICENSE_TOKEN); +} + +function initPhotoEditorSDK() { + SdkEditorModule.initPhotoEditorSDK(LICENSE_TOKEN); } async function openVideoEditor() { - initSDK(); + initVideoEditorSDK(); return await SdkEditorModule.openVideoEditor(); } async function openVideoEditorPIP() { - initSDK(); + initVideoEditorSDK(); return await SdkEditorModule.openVideoEditorPIP(); } async function openVideoEditorTrimmer() { - initSDK(); + initVideoEditorSDK(); return await SdkEditorModule.openVideoEditorTrimmer(); } -async function openIosPhotoEditor() { - await SdkEditorModule.initPhotoEditor(LICENSE_TOKEN); - return await SdkEditorModule.openPhotoEditor(); -} - -async function openAndroidPhotoEditor() { - initSDK(); +async function openPhotoEditor() { + if (Platform.OS === 'android') { + SdkEditorModule.releaseVideoEditor(); + } + SdkEditorModule.initPhotoEditorSDK(LICENSE_TOKEN); return await SdkEditorModule.openPhotoEditor(); } @@ -52,126 +55,160 @@ export default class App extends Component { handleVideoExport(response) { console.log('Export completed successfully: video = ' + response?.videoUri + '; videoPreview = ' - + response?.previewUri); + + response?.previewUri + '; photoUri = ' + response?.photoUri); + } + + handleSdkError(e) { + console.log('handle sdk error = ' + e.code); + + var message = ''; + switch (e.code) { + case 'ERR_SDK_NOT_INITIALIZED': + message = 'Banuba Video Editor SDK is not initialized: license token is unknown or incorrect.\nPlease check your license token or contact Banuba'; + break; + case 'ERR_SDK_EDITOR_LICENSE_REVOKED': + message = 'License is revoked or expired. Please contact Banuba https://www.banuba.com/support'; + break; + case 'ERR_MISSING_EXPORT_RESULT': + message = 'Missing video export result!'; + case 'ERR_CODE_NO_HOST_CONTROLLER': + message = "Host Activity or ViewController does not exist!"; + case 'ERR_VIDEO_EXPORT_CANCEL': + message = "Video export is canceled"; + default: + message = ''; + console.log( + 'Banuba ' + + Platform.OS.toUpperCase() + + ' Video Editor export video failed = ' + + e, + ); + break; + } + this.setState({ errorText: message }); } render() { return ( - - Sample integration of Banuba Video and Photo Editor into React Native - - - - {this.state.errorText} - - - -