The SDK does not work on React Native correctly
hoavo opened this issue · comments
Hoa Vo commented
the code:
"dependencies": {
"phenix-web-sdk": "^2018.4.0",
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.4",
"react-native-webrtc": "^1.67.1"
}
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
getUserMedia
} from 'react-native-webrtc';
global = Object.assign(global, {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
getUserMedia
});
import sdk from 'phenix-web-sdk/dist/phenix-web-sdk-react-native.min';
sdk.RTC.shim();
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = { webrtcSupported: sdk.RTC.webrtcSupported, videoURL: '' };
}
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text>Changes you make will automatically reload.</Text>
<Text>Shake your phone to open the developer menu.</Text>
<Text>{this.state.webrtcSupported ? 'YES' : 'NO'}</Text>
<RTCView style={styles.video} streamURL={this.state.videoURL} />
</View>
);
}
componentDidMount() {
const config = {
backendUri: 'backendUri'
};
const adminApiProxyClient = new sdk.net.AdminApiProxyClient();
adminApiProxyClient.setBackendUri(config.backendUri);
adminApiProxyClient.setAuthenticationDataLocationInPayload('header');
defaultAuth = {
Accept: 'application/vnd.user-backend.v1'
};
adminApiProxyClient.setAuthenticationData({
Authorization: `token`,
...defaultAuth
});
expressOptions = {
adminApiProxyClient,
onError: console.error,
};
const channelExpress = new sdk.express.ChannelExpress({
adminApiProxyClient,
rtmp: {swfSrc: config.rtmpSwfSrc},
});
this.setState({ webrtcSupported: sdk.RTC.webrtcSupported });
channelExpress.joinChannel(
{
alias: 'game364QEXD',
subscriberOptions: {bandwidthToStartAt: 700000}
},
(error, response) => {
if (response && response.channelService) {
this.channelService = response.channelService;
}
},
(error, response) => {
console.info('response', response)
if (response && response.mediaStream) {
console.log('VIDEO URL', response.mediaStream.getStream().toURL());
this.setState({ videoURL: response.mediaStream.getStream().toURL() });
}
}
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
},
video: {
height: 360,
width: '100%'
}
});
Issues:
- The video was being interrupted but audio is work
Screenshot
kylebank commented
Thank you for reporting this issue. Our engineering team is investigating and will get back to you shortly with additional information.
Hoa Vo commented
Thanks for your support
Andrew commented
We believe this issue is addressed by the latest release: https://github.com/PhenixRTS/WebSDK/releases/tag/v2018.4.4
@hoavo Can you confirm?
Hoa Vo commented
yes, it's ok at v2018.4.4