From 22a2655dca4bb53074ce5a74cfeb7f9bb26b13a3 Mon Sep 17 00:00:00 2001 From: Olivier Bouillet <62574056+freeboub@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:53:48 +0100 Subject: [PATCH] fix: ensure save doesn't crash on android (#3415) Co-authored-by: olivier --- examples/basic/src/VideoPlayer.tsx | 30 ++++++++++++++++-------------- src/Video.tsx | 3 ++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/examples/basic/src/VideoPlayer.tsx b/examples/basic/src/VideoPlayer.tsx index 198bf11a..c38b68e0 100644 --- a/examples/basic/src/VideoPlayer.tsx +++ b/examples/basic/src/VideoPlayer.tsx @@ -644,20 +644,22 @@ class VideoPlayer extends Component { onPress={this.onResizeModeSelected} selected={this.state.resizeMode} /> - { - this.video - ?.save({}) - .then(response => { - console.log('Downloaded URI', response); - }) - .catch(error => { - console.log('error during save ', error); - }); - }} - text="save" - /> + {Platform.OS === 'ios' ? ( + { + this.video + ?.save({}) + ?.then(response => { + console.log('Downloaded URI', response); + }) + .catch(error => { + console.log('error during save ', error); + }); + }} + text="save" + /> + ) : null} {this.renderSeekBar()} diff --git a/src/Video.tsx b/src/Video.tsx index 4a718e87..41d2aa64 100644 --- a/src/Video.tsx +++ b/src/Video.tsx @@ -243,7 +243,8 @@ const Video = forwardRef( }, [setIsFullscreen]); const save = useCallback((options: object) => { - return VideoManager.save(options, getReactTag(nativeRef)); + // VideoManager.save can be null on android & windows + return VideoManager.save?.(options, getReactTag(nativeRef)); }, []); const pause = useCallback(() => {