Gathering detailed insights and metrics for react-native-video-gstreamer
Gathering detailed insights and metrics for react-native-video-gstreamer
Gathering detailed insights and metrics for react-native-video-gstreamer
Gathering detailed insights and metrics for react-native-video-gstreamer
npm install react-native-video-gstreamer
Typescript
Module System
Node Version
NPM Version
64
Supply Chain
94.9
Quality
74.9
Maintenance
100
Vulnerability
99.6
License
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
200%
6
Compared to previous week
Last month
9.1%
12
Compared to previous month
Last year
103.2%
252
Compared to previous year
No dependencies detected.
Android only
npm install --save react-native-video-gstreamer
Features:
Todo:
#Install Guide (not tested yet!)
npm install --save react-native-video-gstreamer
In android/setting.gradle
...
include ':ReactNativeMediaPlayerAndroid', ':app'
project(':ReactNativeMediaPlayerAndroid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video-gstreamer/android')
In android/app/build.gradle, add ReactNativeMediaPlayerAndroid library project.
dependencies {
....
compile project(':ReactNativeMediaPlayerAndroid')
}
Register Module in MainAcrivity.java (src/main/java/.../MainActivity.Java)
....
import com.nick.reactnativemediaplayer.MediaPlayerPackage; //add new package component framework for media player
import com.nick.devicecontroller.DeviceControllerPackage; //add new package component framework for device control
.....
.addPackage(new MainReactPackage()) //add new React Native Package for media player
.addPackage(new MediaPlayerPackage())
.addPackage(new DeviceControllerPackage(this))
extract jni libaries 'node_modules/react-native-video-gestreamer/jiniLibs' & copy them (armeabi, armeabi-v7a, ...) into into src/main/jniLibs/
#Example Usage
1'use strict'; 2 3var React = require('react-native'); 4var MediaPlayer = require('react-native-mediaplayer'); 5var {bp, vw, vh} = require('react-native-relative-units')(375); 6var { 7 AppRegistry, 8 StyleSheet, 9 Text, 10 View, 11 TextInput, 12 TouchableOpacity, 13 ToastAndroid 14} = React; 15 16var StreamingState = { 17 DEINITIALIZED : 0 18 , INITIALIZING : 1 19 , INITIALIZED : 2 20 , PLAYING_REQUEST : 3 21 , PLAYING : 4 22 , PAUSED : 5 23 , DEINITIALIZING : 6 24 , ERROR : 7 25}; 26 27var StreamingEvent = { 28 STREAM_STATE_CHANGED : 0 29 , VIDEO_SIZE_CHANGED : 1 30 , STREAM_ERROR : 2 31 , STREAM_MESSAGE : 3 32}; 33 34var ScreenOrientation = { 35 SCREEN_ORIENTATION_UNSPECIFIED : -1 36 , SCREEN_ORIENTATION_LANDSCAPE : 0 37 , SCREEN_ORIENTATION_PORTRAIT : 1 38 , SCREEN_ORIENTATION_USER : 2 39 , SCREEN_ORIENTATION_SENSOR : 4 40}; 41var mediaPlayer = require('react-native').NativeModules.MediaPlayerAndroidModule; 42var deviceController = require('react-native').NativeModules.DeviceContollerModule; 43var ReactNativeStreamingPlayer = React.createClass({ 44 mediaStatus : StreamingState.DEINITIALIZED, 45 mediaURL : "udp://172.20.1.31:1234", 46 mediaVolume: 10, 47 48 /* 49 setURL function: 50 @param1: uri 51 @param2: flag aspect ratio 52 */ 53 54 /* 55 setVolume function: 56 @param: volume (range: 0~100) 0:mute 57 */ 58 selectURL: function() { 59 //ToastAndroid.show(this.state.textValue, ToastAndroid.LONG ); 60 mediaPlayer.setAutoPlay(false); 61 mediaPlayer.setURL(this.state.textValue, true); 62 63 }, 64 65 play: function() { 66 if (this.mediaStatus == StreamingState.DEINITIALIZED) { 67 mediaPlayer.setAutoPlay(true); 68 mediaPlayer.setURL(this.state.textValue, true); 69 } else { 70 mediaPlayer.play(); 71 } 72 73 }, 74 75 pause: function() { 76 //mediaPlayer.pause(); 77 this.mediaVolume += 10; 78 if (this.mediaVolume > 100) { 79 this.mediaVolume = 100; 80 } 81 mediaPlayer.setVolume(this.mediaVolume); 82 }, 83 84 stop: function() { 85 this.mediaVolume = 30; 86 mediaPlayer.setAutoPlay(false); 87 mediaPlayer.stop(); 88 deviceController.setOrientation(ScreenOrientation.SCREEN_ORIENTATION_UNSPECIFIED); 89 }, 90 91 fullScreen: function() { 92 mediaPlayer.setAutoPlay(true); 93 mediaPlayer.setURL(this.state.textValue, false); 94 deviceController.setOrientation(ScreenOrientation.SCREEN_ORIENTATION_LANDSCAPE); 95 }, 96 97 getInitialState: function() { 98 return { 99 textValue: this.mediaURL 100 , mediaStatus: this.mediaStatus 101 } 102 }, 103 104 updateText: function(text) { 105 this.mediaURL = text; 106 this.setState({ 107 textValue: this.mediaURL 108 , mediaStatus: this.mediaStatus 109 }); 110 }, 111 onStreamEvent: function(data) { 112 this.mediaStatus = data.streamState; 113 this.setState({ 114 textValue: this.mediaURL 115 , mediaStatus: this.mediaStatus 116 }); 117 }, 118 119 _renderURI: function () { 120 if (this.state.mediaStatus == StreamingState.PLAYING) { 121 return (<View></View>); 122 } else { 123 return (<View> 124 <Text style={styles.welcome}> 125 Welcome to React Native Player! 126 </Text> 127 <View style={styles.uribar}> 128 <Text style={styles.toolbarButton}> 129 URL: 130 </Text> 131 132 <TextInput 133 ref={component => this._textURI = component} style={styles.textInput} 134 onChangeText={this.updateText} controlled={true} 135 value={this.state.textValue}> 136 </TextInput> 137 138 <TouchableOpacity onPress={this.selectURL}> 139 <Text style={styles.controlButton}> 140 Set URL 141 </Text> 142 </TouchableOpacity> 143 </View> 144 </View>); 145 } 146 }, 147 _renderPlayer: function() { 148 if (this.state.mediaStatus != StreamingState.PLAYING) { 149 return (<View> 150 <MediaPlayer 151 ref={component => this._mediaPlayer = component} 152 style={{ height: vh * 40, width: bp * 350}} 153 onChange={this.onStreamEvent} 154 /> 155 </View>); 156 } else { 157 return (<View> 158 <MediaPlayer 159 ref={component => this._mediaPlayer = component} 160 style={{ height: vh * 80, width: bp * 350}} 161 onChange={this.onStreamEvent} 162 /> 163 </View>); 164 } 165 }, 166 _renderScreen: function() { 167 return ( 168 <View style={styles.container}> 169 {this._renderURI()} 170 <View style={styles.toolbar}> 171 <TouchableOpacity onPress={this.play}> 172 <Text style={styles.controlButton}>Play</Text> 173 </TouchableOpacity> 174 <TouchableOpacity onPress={this.pause}> 175 <Text style={styles.controlButton}>Pause</Text> 176 </TouchableOpacity> 177 <TouchableOpacity onPress={this.stop}> 178 <Text style={styles.controlButton}>Stop</Text> 179 </TouchableOpacity> 180 181 <TouchableOpacity onPress={this.fullScreen}> 182 <Text style={styles.controlButton}>Full</Text> 183 </TouchableOpacity> 184 </View> 185 {this._renderPlayer()} 186 187 </View> 188 ); 189 }, 190 render: function() { 191 return this._renderScreen(); 192 } 193}); 194 195var styles = StyleSheet.create({ 196 container: { 197 flex: 1, 198 justifyContent: 'center', 199 alignItems: 'center', 200 backgroundColor: '#F5FCFF', 201 }, 202 welcome: { 203 fontSize: 20, 204 textAlign: 'center', 205 margin: 10, 206 }, 207 uribar:{ 208 alignItems: 'center', 209 paddingTop:10, 210 paddingBottom:10, 211 flexDirection:'row' //Step 1 212 }, 213 toolbar:{ 214 alignItems: 'center', 215 paddingTop:10, 216 paddingBottom:10, 217 flexDirection:'row' //Step 1 218 }, 219 controlButton:{ 220 color:'#000', 221 backgroundColor:'#aeaeae', 222 justifyContent: 'center', 223 alignItems: 'center', 224 textAlign: 'center', 225 fontWeight:'bold', 226 margin:10, 227 fontSize: 20, 228 paddingLeft: 20 229 }, 230 textInput:{ 231 marginLeft: 10, 232 width: bp * 200, 233 borderWidth: 1, 234 borderColor: "#888888", 235 height: 40 236 } 237}); 238 239AppRegistry.registerComponent('ReactNativeStreamingPlayer', () => ReactNativeStreamingPlayer); 240
#credits All credits to Nicoloas Hagenov (nicoloas.hagenov327@gmail.com) for the good work done.
#disclaimer
This project depend upon other libaries such as gstreamer/plugins, which may have different license. Keep this in mind.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
No security vulnerabilities found.