fix: ensure save doesn't crash on android (#3415)

Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
This commit is contained in:
Olivier Bouillet 2023-12-10 15:53:48 +01:00 committed by GitHub
parent 2462800c9a
commit 22a2655dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 15 deletions

View File

@ -644,20 +644,22 @@ class VideoPlayer extends Component {
onPress={this.onResizeModeSelected} onPress={this.onResizeModeSelected}
selected={this.state.resizeMode} selected={this.state.resizeMode}
/> />
<ToggleControl {Platform.OS === 'ios' ? (
isSelected={this.state.paused} <ToggleControl
onPress={() => { isSelected={this.state.paused}
this.video onPress={() => {
?.save({}) this.video
.then(response => { ?.save({})
console.log('Downloaded URI', response); ?.then(response => {
}) console.log('Downloaded URI', response);
.catch(error => { })
console.log('error during save ', error); .catch(error => {
}); console.log('error during save ', error);
}} });
text="save" }}
/> text="save"
/>
) : null}
</View> </View>
{this.renderSeekBar()} {this.renderSeekBar()}
<View style={styles.generalControls}> <View style={styles.generalControls}>

View File

@ -243,7 +243,8 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
}, [setIsFullscreen]); }, [setIsFullscreen]);
const save = useCallback((options: object) => { 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(() => { const pause = useCallback(() => {