Class: NRTC

NRTC


new NRTC()

请使用 NRTC.getInstance 来初始化音视频环境.

Methods


<static> destroy()

销毁实例

Parameters:
Type Description
Void

<static> getInstance(options)

此接口为单例模式

Parameters:
Name Type Description
options Object

配置参数

Properties
Name Type Argument Default Description
appkey String <optional>

NRTC实例的应用ID

debug Boolean <optional>
false

是否开启debug模式,默认不开启,debug模式下浏览器会打印log日志

chromeId String <optional>
'gapafbpmfemleaplicdhhcikajbogpkf'

屏幕共享插件id


joinChannel(options)

加入频道

Parameters:
Name Type Description
options Object
Properties
Name Type Argument Description
channelName String

频道名称

uid Number

用户唯一标识(建议五位数以上),如果传入则采用传入值,否则SDK自动生成

scene Number <optional>

通话类型:1:双人、2:多人

accid String <optional>

加入频道的用户名称(可重复)

videoDeviceId String <optional>

视频设备ID,不传则默认第一个

audioDeviceId String <optional>

音频设备(输入)ID,不传则默认第一个

joinChannelLiveConfig Object <optional>

加入房间互动直播相关参数

joinChannelRecordConfig Object <optional>

加入房间录制相关参数

Properties
Name Type Argument Description
isHostSpeaker Boolean <optional>

是否是主讲人

recordAudio Boolean <optional>

是否开启音频实时音录制,0不需要,1需要(默认0)

recordVideo Boolean <optional>

是否开启视频实时音录制,0不需要,1需要(默认0)

recordType Number <optional>

录制模式,0混单(产生混合录制文件+单独录制文件) 1只混(只产生混合录制文件) 2只单(只产生单独录制文件)

joinChannelLiveConfig.liveEnable Boolean <optional>

是否旁路直播

joinChannelLiveConfig.rtmpUrl String <optional>

旁路直播地址

joinChannelLiveConfig.rtmpRecord Boolean <optional>

是否开启互动直播录制

joinChannelLiveConfig.splitMode Number <optional>

推流布局模式

joinChannelLiveConfig.layout String <optional>

自定义推流布局

Returns:
Type
Promise

leaveChannel()

离开频道

Parameters:
Type Description
Void
Returns:
Type
Promise

setPlayVolume(options)

播放音量调整

Parameters:
Name Type Description
options Object

配置参数

Properties
Name Type Description
volume Number

音量大小值,取值范围:0-255

account String

账号[WebRTC], 不设置则操作所有远程流

uid String

账号[NRTC], 不设置则操作所有远程流

Returns:

volume 实际设置音量大小,取值范围:0-255

Type
Number

Events


addTrack

addTrack 添加轨道事件-高级用法 WebRTC适用

Type: object

audioVolume

audioVolume 当前所有参与通话者的音量大小实时回调通知 WebRTC适用

Type: object

auidoMixingEnd

auidoMixingEnd 伴音播放完成 WebRTC适用

Type: object

deviceAdd

deviceAdd 新增设备的通知 WebRTC适用

Type: array
Properties:
Name Type Description
device object

设备信息

Properties
Name Type Description
deciveId string

设备ID

type string

设备类型 audioIn audioOut video

label string

设备名


deviceRemove

deviceRemove 设备移除的通知 WebRTC适用

Type: array
Properties:
Name Type Description
device object

设备信息

Properties
Name Type Description
deciveId string

设备ID

type string

设备类型 audioIn audioOut video

label string

设备名


deviceStatus

deviceStatus 设备状态变化通知 WebRTC适用

Type: array
Properties:
Name Type Description
device object

设备信息

Properties
Name Type Description
deciveId string

设备ID

type string

设备类型 audioIn audioOut video

label string

设备名


error

error 错误事件

Type: object
Properties:
Name Type Description
code number

错误码

name string

错误名

desc string

错误原因


gatewayClosed

gatewayClosed 网关连接断开,等待重连/断开 WebRTC适用

Type: object

joinChannel

joinChannel 收到自己加入频道的通知 WebRTC适用

Type: void

leaveChannel

leaveChannel 收到用户离开频道的通知 WebRTC适用

Type: void

recordStopped

recordStopped 音视频录制完成 WebRTC适用

Type: object
Properties:
Name Type Description
id number
name string

音视频录制名称

status string

音视频录制状态

type string

音视频录制类型

uid string

音视频录制的uid


remoteTrack

remoteTrack 收到用户媒体流-高级用法 WebRTC适用

Type: object

removeTrack

removeTrack 删除轨道事件-高级用法 WebRTC适用

Type: object

streamEnded

streamEnded 媒体流停止通知 WebRTC适用

Type: array
Properties:
Name Type Description
device object

设备信息

Properties
Name Type Description
deciveId string

设备ID

type string

设备类型 audioIn audioOut video

label string

设备名


userJoined

userJoined 有用户加入频道的通知 WebRTC适用

Type: object
Properties:
Name Type Description
channelId number

加入频道ID

account number

用户账号(WebRTC有意义)

uid string

用户uid

label string

事件说明


userLeft

userLeft 有用户离开频道的通知 WebRTC适用

Type: object
Properties:
Name Type Description
channelId number

加入频道ID

account number

用户账号(WebRTC有意义)

uid string

用户uid

label string

事件说明

code number

用户离开原因

name string

用户离开原因


userStateUpdated

userStateUpdated 对方音视频状态更新,如开关音视频设备等 WebRTC适用

Type: object