项目作者: sreesharp

项目描述 :
React Native wrapper for Twilio Video SDK
高级语言: Java
项目地址: git://github.com/sreesharp/react-native-twilio-video.git
创建时间: 2017-04-15T00:17:12Z
项目社区:https://github.com/sreesharp/react-native-twilio-video

开源协议:

下载


React Native Twilio Video

React Native wrapper for Twilio Video SDK (Android and iOS)

Current status

This component is under active development now. APIs might break in future updates. Please don’t use it any production ready app yet.

Installation

You need to install the SDK with yarn and configure native Android/iOS project in react native project.

Create React Native project

First create a React Native project:

react-native init YourApp

Install JavaScript packages

Install and link the react-native-twilio-video package:

yarn add https://github.com/sreesharp/react-native-twilio-video

react-native link

Usage

Below snippet is copied from the quickstart sample. VideoView is responsible for rendering both local and remote video stream based on the isLocal attribute. Video is responsible for all the non-ui related methods and event callbacks.

  1. const TwilioSDK = require('react-native-twilio-video');
  2. const {
  3. Video,
  4. VideoView,
  5. } = TwilioSDK;
  6. // add listeners
  7. Video.addEventListener('onRoomConnected', roomConnectedHandler);
  8. Video.addEventListener('onParticipantConnected', participantConnectedHandler);
  9. ....
  10. _onConnect() {
  11. //Get the access token from server
  12. const ACCESS_TOKEN = "YOUR_TWILIO_ACCESS_TOKEN";
  13. Video.startCall({roomName: this.state.roomName, accessToken: ACCESS_TOKEN});
  14. }
  15. ...
  16. render() {
  17. return (
  18. <View style={styles.container}>
  19. <VideoView isLocal={false} style={styles.fullView}></VideoView>
  20. <View style={styles.bottomView}>
  21. <VideoView isLocal={true} style={styles.thumbnailView}></VideoView>
  22. <View style={styles.controlsView}>
  23. <View style={styles.bottomView}>
  24. {this.renderCallButton()}
  25. {this.renderCameraButton()}
  26. </View>
  27. <View style={styles.bottomView}>
  28. {this.renderVideoButton()}
  29. {this.renderAudioButton()}
  30. </View>
  31. </View>
  32. </View>
  33. </View>
  34. );
  35. }

Quickstart sample in action

Video Walkthrough