Is there a way to stream video in react-native?

If you build your app using Expo (i.e. running the create-react-native-app command), then the Expo library includes a video component.

Here is a code sample:

<Video
  source={{ uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4' }}
  rate={1.0}
  volume={1.0}
  muted={false}
  resizeMode="cover"
  shouldPlay
  isLooping
  style={{ width: 300, height: 300 }}
/>

I suppose Expo is technically a library. To my knowledge, there is no video library built into react-native. You will need to use a package.


If you are using react-native with native code(not using expo) : https://github.com/react-native-community/react-native-video

<Video source={{uri: "background"}}   // Can be a URL or a local file.
   ref={(ref) => {
     this.player = ref
   }}                                      // Store reference
   onBuffer={this.onBuffer}                // Callback when remote video is buffering
   onError={this.videoError}               // Callback when video cannot be loaded
   style={styles.backgroundVideo} />

and also there is the need to link the libraries