Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Does react-native support video component(Officially, like without using any 3rd party libs)? I want to stream/playback a video from my cloud and looking for a way to integrate it to my react-native project.

Thanks in advance, any leads to the solution will be helpful.

like image 202
HungrySoul Avatar asked Oct 26 '17 13:10

HungrySoul


People also ask

Is Netflix using React Native?

Netflix runs React native on all devices.

Does React Native video support HLS?

React Native Video is very popular player to play videos on react native applications. It can play both HLS and DASH streams and supports DRM.


2 Answers

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.

like image 139
Tom Aranda Avatar answered Oct 21 '22 02:10

Tom Aranda


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

like image 26
osdamv Avatar answered Oct 21 '22 00:10

osdamv