From beaa66eee4af4fea13dba98736d7198c4d9fecbc Mon Sep 17 00:00:00 2001 From: olivier Date: Sun, 10 Dec 2023 12:36:23 +0100 Subject: [PATCH] fix: ensure save doesn't crash on android --- 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 198bf11a40..c38b68e062 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 4a718e87b7..41d2aa6497 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(() => {