user9840214
user9840214

Reputation:

react-native-video with dynamic url

I'm using fetch to call API for video URL. I have trouble with react-native-video.the video is not showing.

<Video
  repeat
  resizeMode='cover'
  source={{uri:`${this.state.base_url}${item.video}`}} 
  style = {styles.backgroundVideo} 
/>

I'm getting a blank screen. In documentation, they mention like below code.

source={require('../assets/video/turntable.mp4')}

How can I render dynamic URL like mentioned above? Thanks

Upvotes: 1

Views: 1218

Answers (1)

Solly
Solly

Reputation: 524

I am using this compoenet and it's working properly, fetching from API.

<Video
  source={{
    uri: this.state.waitingVideoURL,
  }}
  resizeMode="cover"
  style={styles.backgroundVideo}
  repeat
  onLoad={this.stopLoading}
/>

In your code, why you having two variables in the source; What's item.video ?

source={{uri:`${this.state.base_url}${item.video}`}} 

Upvotes: 1

Related Questions