No Description
matrixbirds a4e9ecc6e2 update docs 5 years ago
android fix. convert 5 years ago
docs add docs 5 years ago
ios fix. typo 5 years ago
lib refactor. event 5 years ago
samples refactor. event 5 years ago
src refactor. event 5 years ago
.gitattributes git lfs 5 years ago
.gitignore add doc & changelog 5 years ago
.npmignore add doc & changelog 5 years ago
CHANGELOG add doc & changelog 5 years ago
LICENSE v1.1.2 6 years ago
README.md update docs 5 years ago
README.old.md add gitter and api docs 5 years ago
package.json update. version 2.3.3-alpha.5 5 years ago
react-native-agora.podspec release 2.3.3-alpha.0 5 years ago
tsconfig.json stash 5 years ago
yarn.lock fix conflicts 5 years ago

README.md

有任何问题欢迎加入QQ群进行反馈 471757030

for 1.x old version

react-native-agora

npm npm npm npm join chat

Description

The react-native-agora is an open-source wrapper for react-native developers. This SDK takes advantage of React Native and Agora RTC Video SDKs on Android/iOS.

Compatibility

  • react native 0.58.x
  • iOS SDK 8.0+
  • Android 5.0+ x86 arm64 armv7a

quick start

Installation

Install with npm:

npm install --save react-native-agora

Or, install with yarn:

yarn add react-native-agora

Either way, then link with:

react-native link react-native-agora

iOS Installation

中文 English

Android Installation

中文 English

Agora Native API Documentation

Android

中文 English

iOS

中文 English

RtcEngine Methods

Method Name Parameters Description
init Option create and initialize AgoraRtcEngine instance, notice: invoke this method, it will start subscribe events
Promise joinChannel String channelName, Number uid, String? token, String? extraInfo join channel
on String: EventType, Handler: Function addEventListener for native module events
off String: EventType removeEventListeners for native module events
removeAllListeners void remove all event listeners
destroy void destroy AgoraRtcEngine instance
getSdkVersion Function: callback get sdk version
Promise enableLastmileTest void enable network quality test
Promise disableLastmileTest void disable network quality test
Promise leaveChannel void quit channel
setupLocalVideo Number: uid, Number: renderMode, Number: reactTag setup local video
setupRemoteVideo Number: uid, Number: renderMode, Number: reactTag setup remote video
startPreview void open video preview
stopPreview void close video preview
setLiveTranscoding LiveTranscoding start live trancoding
setLocalRenderMode Number: mode set local video render mode
setRemoteRenderMode Number: uid, Number: mode set remote video render mode
enableAudioVolumeIndication Number: interval, Number smooth enable speaker volume notification
Promise switchCamera void switch mobile camera
enableVideo void enable video
disableVideo void disable video
setEnableSpeakerphone Boolean: enabled set enable speaker phone
Promise setCameraAutoFocusFaceModeEnabled Boolean: enabled set camera auto focus face mode
setDefaultAudioRouteToSpeakerphone Boolean: enabled set default audio route to speaker phone
Promise setCameraTorchOn Boolean: enabled set camera torch on
muteLocalAudioStream Boolean: enabled mute/unmute local audio
muteRemoteAudioStream Number: uid, Boolean: enabled mute/unmute remote audio by uid
muteAllRemoteAudioStreams Boolean: enabled mute/unmute all remote audio
muteLocalVideoStream Boolean: enabled mute/unmute local video stream
enableLocalVideo Boolean: enabled set enabled status to local video
muteAllRemoteVideoStreams void mute/unmute all remote videos
muteRemoteVideoStream Number: uid, Boolean: enabled mute/unmute remote video by uid
Promise createDataStream Boolean: reliable, Boolean: ordered createDataStream
Promise renewToken String: token renew token
Promise getConnectionState void return connection state
setClientRole Number: role(1: host, 2: audience) change client role
enableAudio void enable audio
disableAudio void disable audio
enableLocalAudio Boolean: enable enable/disable local audio
muteLocalAudioStream Boolean: mute enable/disable local audio stream
muteAllRemoteAudioStreams Boolean: mute enable/disable all remote audio streams
muteRemoteAudioStream Number: uid, Boolean: mute mute/unmute remote audio stream by uid
adjustRecordingSignalVolume Number: volume Adjusts the recording volume.
adjustPlaybackSignalVolume Number: volume Adjusts the playback volume.
enableAudioVolumeIndication Number: interval, Number: smooth Enables the onAudioVolumeIndication callback at a set time interval to report on which users are speaking and the speakers’ volume.
Promise startAudioRecording {filePath: String, quality: int} start audio recording
Promise stopAudioRecoding void stop audio recording
methodisSpeakerphoneEnabled void Checks whether the speakerphone is enabled.
setInEarMonitoringVolume Number: volume Sets the volume of the in-ear monitor.
setLocalVoicePitch Number(double): pitch Changes the voice pitch of the local speaker.
setLocalVoiceEqualization Number: bandFrequency, Number: bandGain Sets the local voice equalization effect.
setLocalVoiceReverb Number: reverbKey, Number: value Sets the local voice reverberation.
startAudioMixing {filepath: String, loopback: Boolean, replace: Boolean, cycle: Int} android
& ios
stopAudioMixing void
pauseAudioMixing void
resumeAudioMixing void
adjustAudioMixingVolume Number: volume
adjustAudioMixingPlayoutVolume Number: volume
adjustAudioMixingPublishVolume Number: volume
Promise getAudioMixingDuration void
Promise getAudioMixingCurrentPosition void
Promise setAudioMixingPosition Number: pos
Promise getEffectsVolume void
Promise setEffectsVolume Number(double): volume
Promise setVolumeOfEffect Number: soundId, Number(double): volume
Promise playEffect {soundId: Number, filePath: String, loopCount: Number, pitch: Number(double), gain: Boolean, publish: Boolean}
Promise stopEffect Number: soundId
Promise stopAllEffects void
Promise preloadEffect Number: soundid, String: filepath
Promise unloadEffect Number: soundId
Promise pauseEffect Number: soundId
Promise pauseAllEffects void
Promise resumeEffect void
Promise resumeAllEffects void
setAudioSessionOperationRestriction void
Promise startEchoTest void
Promise stopEchoTest void
Promise setRecordingAudioFrameParameters {sampleRate: Number, channel: Number, mode: Number, samplesPerCall: Number }
Promise setPlaybackAudioFrameParameters {sampleRate: Number, channel: Number, mode: Number, samplesPerCall: Number }
Promise addVideoWatermark {url: String, x: Number, y: Number, width: Number, height: Number }
clearVideoWatermarks void
setLocalPublishFallbackOption Number: option(0, 1, 2)
setRemoteSubscribeFallbackOption Number: option (0, 1, 2)
Promise enableDualStreamMode Boolean: enabled
setRemoteVideoStreamType { uid: Number, streamType: Number }
setRemoteDefaultVideoStreamType { streamType: Number }
Promise addInjectStreamUrl InjectionStream
Promise removePublishStreamUrl String: url
Promise setVideoQualityParameters Boolean: quality
Sets the preference option for the video quality (Live broadcast only).
Promise setLocalVideoMirrorMode Number: mode
Promise switchCamera void
Promise isCameraZoomSupported void
Promise isCameraTorchSupported void
Promise isCameraFocusSupported void
Promise isCameraExposurePositionSupported void
Promise isCameraAutoFocusFaceModeSupported void
Promise setCameraZoomFactor Number(float): zoomFactor
Promise getCameraMaxZoomFactor void
Promise setCameraFocusPositionInPreview {x: Number(double), y: Number(double) }
Promise setCameraExposurePosition {x: Number(double), y: Number(double) }
Promise setCameraTorchOn Boolean isOn
Promise setCameraAutoFocusFaceModeEnabled Boolean enabled
Promise getCallId void
Promise setLog filePath: String, level: Number
addPublishStreamUrl { url: String, enabled: Boolean }
removePublishStreamUrl { url: String }

Option

export interface Option {
  appid: String,
  videoProfile: number
  channelProfile: number,
  videoEncoderConfig: VideoEncoderConfig,
  clientRole: number,
  audioProfile: number,
  audioScenario: number
}

export interface VideoEncoderConfig {
  width: number,
  height: number,
  bitrate: number,
  frameRate: number,
  orientationMode: number,
}

LiveTranscoding

export interface LiveTranscoding {
  size: Size,
  videoBitrate: number,
  videoFramerate: number,
  lowLatency: boolean,
  videoGop: number,
  videoCodecProfile: number,
  transcodingUsers: Array<TranscodingUser>,
  transcodingExtraInfo: string,
  watermark: BackgroundImage,
  backgroundImage: BackgroundImage,
  backgroundColor: Color,
  audioSampleRate: number,
  audioBitrate: number,
  audioChannels: number,
}

InjectionStream

export interface InjectionStream {
  config: {
    size: {
      width: Number,
      height: Number,
    },
    videoGop: Number,
    videoBitrate: Number,
    audioBitrate: Number,
    audioSampleRate: Number,
    videoFrameRate: Number
    audioChannels: Number
  }
}

Events

RtcEngine.on('eventName', (data) => {
    console.log(data);
});
Name Description Platform
warning warning all
error error all
apiCallExecute capture agora native api call executed all
joinChannelSuccess join channel success all
reJoinChannelSuccess rejoin channel success all
leaveChannel quit channel all
clientRoleChanged when changed client role all
userJoined when user joined channel all
userOffline when user left channel all
connectionStateChanged when connection state changed all
connectionLost when connection lost all
tokenPrivilegeWillExpire when token will expire all
requestToken when token expired all
microphoneEnabled when microphone enabled all
audioVolumeIndication notice audio volume all
activeSpeaker reports which user is the loudest speaker all
firstLocalAudioFrame when the first local audio frame is sent all
firstRemoteAudioFrame when the first remote audio frame is sent all
videoStopped when video stopped all
firstLocalVideoFrame when first local video frame is sent all
firstRemoteVideoDecoded when first remote video is decoded all
firstRemoteVideoFrame when first remote video frame is rendered all
userMuteAudio when a remote user’s audio stream is muted/unmuted all
userMuteVideo when a remote user’s video stream is muted/unmuted all
userEnableVideo when a remote user enables/disables the video module all
userEnableLocalVideo when a remote user enables/disables the local video capture function all
videoSizeChanged when the video size or rotation information of a specified remote user changes all
remoteVideoStateChanged when the remote video stream state changes all
localPublishFallbackToAudioOnly Occurs when the published video stream falls back to an audio-only stream due to unreliable network conditions or switches back to the video when the network conditions improve. all
remoteSubscribeFallbackToAudioOnly Occurs when the remote video stream falls back to an audio-only stream due to unreliable network conditions or switches back to the video after the network conditions improve. all
audioRouteChanged when the local audio pkayout route changes all
cameraReady when the camera is turned on and ready to capture video all
cameraFocusAreaChanged when the camera focus area is changed all
cameraExposureAreaChanged The camera exposure area has changed all
remoteAudioStats Reports the statistics of the audio stream from each remote user/host. all
rtcStats Reports the statistics of the RtcEngine once every two seconds all
lastmileQuality Reports the last mile network quality of the local user once every two seconds before the user joins the channel. Last mile refers to the connection between the local device and Agora’s edge server. After the application calls the enableLastmileTest method, this callback reports once every two seconds the uplink and downlink last mile network conditions of the local user before the user joins the channel. all
networkQuality Reports the last mile network quality of each user in the channel once every two seconds. Last mile refers to the connection between the local device and Agora’s edge server. This callback reports once every two seconds the uplink last mile network conditions of each user in the channel. If a channel includes multiple users, then this callback will be triggered as many times. all
localVideoStats Reports the statistics of the uploading local video streams. This callback is triggered once every two seconds for each individual user/host. If there are multiple users/hosts in the channel, this callback is triggered multiple times every 2 seconds. all
remoteVideoStats Reports the statistics of the video stream from each remote user/host. The SDK triggers this callback once every two seconds for each remote user/host. If a channel includes multiple remote users, the SDK triggers this callback as many times. This callback reports statistics more closely linked to the real-user experience of the video transmission quality than the statistics that the onRemoteVideoTransportStats callback reports all
audioTransportStatsOfUid Reports the transport-layer statistics of each remote audio stream. all
videoTransportStatsOfUid Reports the transport-layer statistics of each remote video stream. all
localAudioMixingFinish Occurs when the audio mixing file playback finishes. all
remoteAudioMixingStart Occurs when a remote user starts audio mixing. ios
remoteAudioMixingFinish Occurs when a remote user finishes audio mixing. ios
audioEffectFinish Occurs when the audio effect file playback finishes. all
streamPublished Occurs when a CDN live stream is published. all
streamUnpublish Occurs when CDN live streaming stops. This callback notifies the host that the CDN live stream is unpublished. all
transcodingUpdate Occurs when the publisher’s transcoding settings are updated. all
streamInjectedStatus Reports the status of the injected online media stream. all
receiveStreamMessage Occurs when the local user receives a remote data stream within five seconds. all
occurStreamMessageError Occurs when the local user fails to receive a remote data stream. all
mediaEngineLoaded Occurs when the media engine is loaded. all
mediaEngineStartCall Occurs when the media engine starts. all
AgoraView Component
Name Description
showLocalVideo boolean: (true
remoteUid uid for remote
zOrderMediaOverlay (Android only) enable zorder to media overlay

samples

  • need react-native 0.58.+

Samples