react native + how to read a local file code example

Example 1: uri : source{require (`${RNFS.DocumentDirectoryPath}/`

import Video from "react-native-video";

<Video
  source={{ uri: this.state.videoUri }} // Can be a URL or a local file.
  ref={ref => {
    this.player = ref;
  }} // Store reference
  onError={this.videoError} // Callback when video cannot be loaded
/>;

Example 2: uri : source{require (`${RNFS.DocumentDirectoryPath}/`

let fileName = videoURL.substring(videoURL.lastIndexOf("/") + 1, videoURL.length);

this.getVideoUrl(videoURL, fileName)
  .then(res => {
    this.setState({ videoUri: res });
  })
  .catch(url => {
    this.setState({ videoUri: url });
  });


getVideoUrl = (url, filename) => {
  return new Promise((resolve, reject) => {
    RNFS.readDir(RNFS.DocumentDirectoryPath)
      .then(result => {
        result.forEach(element => {
          if (element.name == filename.replace(/%20/g, "_")) {
            resolve(element.path);
          }
        });
      })
      .catch(err => {
        reject(url);
      });
  });
};

Example 3: uri : source{require (`${RNFS.DocumentDirectoryPath}/`

let filename = videoUrl.substring(deviceuri.lastIndexOf("/") + 1, videoUrl.length);
let path_name = RNFS.DocumentDirectoryPath + filename;

RNFS.exists(path_name).then(exists => {
  if (exists) {
    console.log("Already downloaded");
  } else {
    RNFS.downloadFile({
      fromUrl: videoUrl,
      toFile: path_name.replace(/%20/g, "_"),
      background: true
    })
      .promise.then(res => {
        console.log("File Downloaded", res);
      })
      .catch(err => {
        console.log("err downloadFile", err);
      });
  }
});