fix: ensure save doesn't crash on android (#3415)
Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
This commit is contained in:
		| @@ -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}> | ||||
|   | ||||
| @@ -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(() => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user