Search code examples
react-nativeuiimagepickercontroller

video selected through ImagePicker not visible using react-native-video


I am using react-native-ImagePicker and react-native-video packages. I selected a video using ImagePicker and it worked perfectly fine.

Now what I want is to display the selected video for which I am using react-native-video as follows

`<Video source={source}
       ref={(ref) => {
         this.player = ref
       }}
       rate={1.0}                              // 0 is paused, 1 is normal.
       volume={1.0}                            // 0 is muted, 1 is normal.
       muted={false}                           // Mutes the audio entirely.
       paused={false}                          // Pauses playback entirely.
       resizeMode="cover"                      // Fill the whole screen at aspect ratio.*
       repeat={true}                           // Repeat forever.
       playInBackground={false}                // Audio continues to play when app entering background.
       playWhenInactive={false}                // [iOS] Video continues to play when control or notification center are shown.
       ignoreSilentSwitch={"ignore"}           // [iOS] ignore | obey - When 'ignore', audio will still play with the iOS hard silent switch set to silent. When 'obey', audio will toggle with the switch. When not specified, will inherit audio settings as usual.
       progressUpdateInterval={250.0}          // [iOS] Interval to fire onProgress (default to ~250ms)
       onLoadStart={this.loadStart}            // Callback when video starts to load
       onLoad={this.setDuration}               // Callback when video loads
       onProgress={this.setTime}               // Callback every ~250ms with currentTime
       onEnd={this.onEnd}                      // Callback when playback finishes
       onError={this.videoError}               // Callback when video cannot be loaded
       onBuffer={this.onBuffer}                // Callback when remote video is buffering
       onTimedMetadata={this.onTimedMetadata}/>`

where source is

`source = videoUrl.split("file://")[1]`

Solution

  • I got it working. <Video> was missing style. Once i set it it worked perfectly fine.

    I more thing sometime an error comes "cannot read constant of undefined" this is because video library is not linked properly. Delete and add again in xCode and the error will go