Last active
January 10, 2018 10:33
-
-
Save prabakarviji/396e9cad24584dbbf984f351f3428971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { StyleSheet, Text, View, TouchableOpacity,Dimensions } from "react-native"; | |
import OpenTok, { Subscriber } from 'react-native-opentok'; | |
const sessionId = 'YOUR_OPENTOK_SESSIONID'; | |
const token = 'YOUR_OPENTOK_SUBSCRIBER_TOKEN'; | |
export default class Viewer extends Component<{}> { | |
async componentWillMount() { | |
await OpenTok.connect(sessionId, token); | |
OpenTok.on(OpenTok.events.ON_SIGNAL_RECEIVED, e => console.log(e)); | |
} | |
ref: Ref<typeof Viewer>; | |
render() { | |
return ( | |
<View style={styles.container}> | |
<View style={{flex:0.9}}> | |
<Subscriber | |
sessionId={sessionId} | |
onSubscribeStart={() => { console.log('Watching started')}} | |
onSubscribeStop={() => { console.log('Watching started')} | |
onSubscribeError={() => { console.log('Watching started')} | |
style={{backgroundColor: 'black',height:height, width: width, }} | |
ref={ref => { | |
this.ref = ref; | |
}} | |
/> | |
</View> | |
... | |
); | |
} | |
cancelAndBack(){ | |
OpenTok.disconnect(sessionId) | |
this.props.navigation.goBack() | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment