使用react-native-video

时间:2017-04-26 12:44:54

标签: react-native uiimagepickercontroller

我正在使用react-native-ImagePicker和react-native-video软件包。 我使用ImagePicker选择了一个视频,它工作得很好。

现在我想要的是显示我正在使用的所选视频 react-native-video如下

`<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}/>`

来源

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

1 个答案:

答案 0 :(得分:0)

我得到了它的工作。 <Video>缺少风格。一旦我设置它,它工作得非常好。

我有时会出现错误“无法读取未定义的常量”这是因为视频库没有正确链接。在xCode中再次删除并添加,错误将会消失