Skip to content

Commit

Permalink
fix: ensure save doesn't crash on android (#3415)
Browse files Browse the repository at this point in the history
Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
  • Loading branch information
freeboub and olivier committed Dec 10, 2023
1 parent 2462800 commit 22a2655
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
30 changes: 16 additions & 14 deletions examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,20 +644,22 @@ class VideoPlayer extends Component {
onPress={this.onResizeModeSelected}
selected={this.state.resizeMode}
/>
<ToggleControl
isSelected={this.state.paused}
onPress={() => {
this.video
?.save({})
.then(response => {
console.log('Downloaded URI', response);
})
.catch(error => {
console.log('error during save ', error);
});
}}
text="save"
/>
{Platform.OS === 'ios' ? (
<ToggleControl
isSelected={this.state.paused}
onPress={() => {
this.video
?.save({})
?.then(response => {
console.log('Downloaded URI', response);
})
.catch(error => {
console.log('error during save ', error);
});
}}
text="save"
/>
) : null}
</View>
{this.renderSeekBar()}
<View style={styles.generalControls}>
Expand Down
3 changes: 2 additions & 1 deletion src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
}, [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(() => {
Expand Down

0 comments on commit 22a2655

Please sign in to comment.