1

I'm working on this app that does not always hold the video content on the device. The Video will be downloaded, and then a path to the video will be on json objects that need to be inputed into a require. (or thats how I do it right now)

This is the code for the video:

  import jsonFileExercise from '../../../assets/controller/data/getNextExerciseBySectionId.json'

  var videoPath = jsonFileExercise.content.path

  return (
    <Video
      source={require(videoPath)}
      rate={1.0}
      volume={1.0}
      isMuted={false}
      resizeMode="cover"
      //shouldPlay
      useNativeControls
      isLooping
      style={styles.backgroundVideo}
    />
  )

This is the JSON file

{
  "exerciseId": 1,
  "content": {
    "type": "video",
    "path": "../video/content/testvideo2.mp4"
  }
}

I want to be able to change the path in the JSON file and then load a different video. Does anyone know a better way of having Dynamic Video that is loaded from storage?

Another problem is going to be using images from asyncStorage, but the ideal solution would be something that uses both images from AsyncStorage and updating images dynamically.

Similar posts: React Native: require() with Dynamic String? But it did not show a solution for the issue.

0 Answers0