- Support only for android
$ npm install react-native-mjpeg-player --save
$ react-native link react-native-mjpeg-player
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.segware.RNMjpegPlayerPackage;to the imports at the top of the file - Add
new RNMjpegPlayerPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-mjpeg-player' project(':react-native-mjpeg-player').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mjpeg-player/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-mjpeg-player')
importReactfrom'react';importMjpegPlayerfrom'react-native-mjpeg-player';classMjpegPlayerComponentextendsReact.Component{render(){const{ url, width, height }=this.props;return(<MjpegPlayerref={ref=>{this.mjpegPlayer=ref;}}style={{width: `100%`,height: `100%`}}settings={{
url,
width,
height
}}/>);}}exportdefaultMjpegPlayerComponent;| Prop | Description | Type | Default |
|---|---|---|---|
| url | mjpeg url stream | string | required |
| width | frame width | number | required |
| height | frame height | number | required |