react-native-nodemediaclient
react-native-nodemediaclient copied to clipboard
Works fine on iOS but on android the status i receive on start is event = "2000" or "2001" while on iOS its e.nativeEvent.msg = "NetStream.Publish.Start"
I want to use this package but there is basically no documentation. Works fine on iOS as i said, but im receiving different status codes that cause my app to crash on android and have no way of debugging it. Does anyone know why the app is crashing on android only? I'll attach my code for my streamer below. I can see the video from my webcam on the android emulator so i don't think i set it up incorrectly for android. Its only when i hit the start button the app crashes but as i said it works perfectly on iOS. the "e" argument in handleConnection is returning a number instead of an object like it does on iOS.
handleConnection = (e) => {
if (e.nativeEvent.msg === 'NetStream.Publish.Start') {
this.setState({streamingStarted: true});
this.counter = setInterval(() => {
this.setState({timer: this.state.timer + 1});
}, 1000);
SocketTools.socketStartStreaming();
} else if (e.nativeEvent.msg === 'NetConnection.Connect.Closed') {
this.setState({timer: 0, streamingStarted: false});
SocketTools.socketStopStreaming();
clearInterval(this.counter);
}
};
componentDidMount = () => {
Platform.OS === 'android' && this.requestCameraPermission();
this.vb.switchCamera();
};
componentWillUnmount = () => {
SocketTools.socketStopStreaming();
this.vb.stop();
};
requestCameraPermission = async () => {
try {
const granted = await PermissionsAndroid.requestMultiple(
[
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
],
{
title: 'Alert Camera And Microphone Permission',
message: 'Alert App needs access to your camera ',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('You can use the camera');
} else {
console.log('Camera permission denied');
}
} catch (err) {
console.warn(err);
}
};
<NodeCameraView
style={{flex: 1, width: '100%'}}
ref={vb => {
this.vb = vb;
}}
onStatus={this.handleConnection}
outputUrl={`rtmp://********************`}
camera={{cameraId: 1, cameraFrontMirror: true}}
audio={{bitrate: 32000, profile: 1, samplerate: 44100}}
video={{
preset: 1,
bitrate: 8000000,
profile: 0,
fps: 30,
videoFrontMirror: false,
}}
autopreview={true}
/>
Use version v0.2.0,
https://github.com/NodeMedia/iShow-RN/blob/master/PushScreen.js#L34
Hi, Thank you for the reply. I updated the version but im still getting these status codes on android instead of Netstream.Publish.start like i do on iOS. I've looked through every github issue, the nodemodule files, and the provided documentation and have no clue what 2000 or 2001 means. Here is my callback for onstatus. Do you know what the numbers mean?
Thanks, Matt handleConnection = (a, b) => { console.log(a, b); // console.log('EEEEEEEEEE', e); // if (e.nativeEvent.msg === 'NetStream.Publish.Start') { // this.setState({streamingStarted: true}); // this.counter = setInterval(() => { // this.setState({timer: this.state.timer + 1}); // }, 1000); // SocketTools.socketStartStreaming(); // } else if (e.nativeEvent.msg === 'NetConnection.Connect.Closed') { // this.setState({timer: 0, streamingStarted: false}); // SocketTools.socketStopStreaming(); // clearInterval(this.counter); // } }; <NodeCameraView style={{flex: 1, width: '100%'}} ref={vb => { this.vb = vb; }} onStatus={e => console.log(e)} outputUrl={`rtmp://*******} camera={{cameraId: 1, cameraFrontMirror: true}} audio={{bitrate: 32000, profile: 1, samplerate: 44100}} video={{ preset: 1, bitrate: 8000000, profile: 0, fps: 30, videoFrontMirror: false, }} autopreview={true} />
[image: Screen Shot 2020-07-01 at 12.20.15 PM.png]
On Wed, Jul 1, 2020 at 12:07 PM Chen Mingliang [email protected] wrote:
Use version v0.2.0,
https://github.com/NodeMedia/iShow-RN/blob/master/PushScreen.js#L34
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NodeMedia/react-native-nodemediaclient/issues/92#issuecomment-652509341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPVTERXSBX5ZPZNO6FGGSTRZNNLBANCNFSM4OMMJN4A .
Ok I noticed an issue in my code where i wasn't logging the correct thing after updating, please ignore my last email. I will continue to test before I ask anything else.
My apologies, Matt
On Wed, Jul 1, 2020 at 12:23 PM Matt G. [email protected] wrote:
Hi, Thank you for the reply. I updated the version but im still getting these status codes on android instead of Netstream.Publish.start like i do on iOS. I've looked through every github issue, the nodemodule files, and the provided documentation and have no clue what 2000 or 2001 means. Here is my callback for onstatus. Do you know what the numbers mean?
Thanks, Matt handleConnection = (a, b) => { console.log(a, b); // console.log('EEEEEEEEEE', e); // if (e.nativeEvent.msg === 'NetStream.Publish.Start') { // this.setState({streamingStarted: true}); // this.counter = setInterval(() => { // this.setState({timer: this.state.timer + 1}); // }, 1000); // SocketTools.socketStartStreaming(); // } else if (e.nativeEvent.msg === 'NetConnection.Connect.Closed') { // this.setState({timer: 0, streamingStarted: false}); // SocketTools.socketStopStreaming(); // clearInterval(this.counter); // } }; <NodeCameraView style={{flex: 1, width: '100%'}} ref={vb => { this.vb = vb; }} onStatus={e => console.log(e)} outputUrl={`rtmp://*******} camera={{cameraId: 1, cameraFrontMirror: true}} audio={{bitrate: 32000, profile: 1, samplerate: 44100}} video={{ preset: 1, bitrate: 8000000, profile: 0, fps: 30, videoFrontMirror: false, }} autopreview={true} />
[image: Screen Shot 2020-07-01 at 12.20.15 PM.png]
On Wed, Jul 1, 2020 at 12:07 PM Chen Mingliang [email protected] wrote:
Use version v0.2.0,
https://github.com/NodeMedia/iShow-RN/blob/master/PushScreen.js#L34
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NodeMedia/react-native-nodemediaclient/issues/92#issuecomment-652509341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPVTERXSBX5ZPZNO6FGGSTRZNNLBANCNFSM4OMMJN4A .