Skip to main content
Version: 2.16

Play WebRTC Stream Using React Native SDK

  1. Open the /example/src/Play.tsx file and update the defaultStreamName variable for streamId and the webSocketUrl variable with your server domain or IP address.

  1. Open the /examples/android folder and provide read, write, and execute permissions to the gradlew file.
chmod 750 gradlew
  1. Move to the examples folder, edit the below index.js file as below:
import { AppRegistry } from 'react-native';
//import App from './src/App';
import App from './src/Play';
//import App from './src/Peer';
//import App from './src/Conference';
//import App from './src/Chat';
import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, () => App);
  1. Run the below commands to run the Play sample React native app.
npm install
npm run android
  1. Before playing, make sure that a stream is already published to the server with the same stream ID as in your defaultStreamName variable. You can quickly publish a WebRTC stream via the sample page:

https://your_domain:5443/WebRTCAppEE

  1. Click the Start Playing button on the screen to play the stream published on the server.

Congratulations!

You’ve successfully set up the React Native app to play a WebRTC stream from your Ant Media Server! Your app can now receive live streams in real time, enabling you to watch broadcasts directly from your mobile device. Enjoy exploring the streaming features and testing different stream sources.