Interfaces
Methods
(static) getTRTCShareInstance()
获取 TRTCCloud 实例(单例模式)
(static) destroyTRTCShareInstance()
销毁 TRTCCloud 实例(单例模式)
on()
off()
emit()
enterRoom()
exitRoom()
switchRoom()
switchRole()
切换角色,仅适用于直播场景(TRTCAppSceneLIVE 和 TRTCAppSceneVoiceChatRoom)
startLocalPreview()
启动本地摄像头采集和预览
stopLocalPreview()
停止本地摄像头采集和预览
updateLocalView()
修改本地摄像头预览的 HTML 元素,小程序不支持
muteLocalVideo(mute, streamType)
暂停/恢复发布本地的视频流
Parameters:
Name | Type | Description |
---|---|---|
mute |
boolean |
true:屏蔽;false:开启,默认值:false |
streamType |
TRTCVideoStreamType |
要暂停/恢复的视频流类型, 仅支持 TRTCVideoStreamTypeBig 和 TRTCVideoStreamTypeSub |
startRemoteView(userId, view, streamType)
开始显示远端视频画面
Parameters:
Name | Type | Description |
---|---|---|
userId |
对方的用户标识 |
|
view |
此参数无效,小程序不支持 |
|
streamType |
视频流类型 |
stopRemoteView(userId, streamType)
停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
Parameters:
Name | Type | Description |
---|---|---|
userId |
对方的用户标识 |
|
streamType |
视频流类型 |
updateRemoteView(userId, view, streamType)
修改远端视频渲染的 HTML 元素,小程序不支持
Parameters:
Name | Type | Description |
---|---|---|
userId |
远端视频流的用户 ID |
|
view |
接受远端视频流渲染的 HTML 元素,传入 null 结束远端视频的渲染
|
|
streamType |
Returns:
switchCamera()
切换前后摄像头
(static) getTRTCShareInstance() → {TRTCCloud}
获取 TRTCCloud 实例(单例模式)
Returns:
- Type
- TRTCCloud
(static) destroyTRTCShareInstance() → {void}
销毁 TRTCCloud 实例(单例模式)
Returns:
- Type
- void
on(eventName, handler, context) → {void}
Parameters:
Name | Type | Description |
---|---|---|
eventName |
||
handler |
||
context |
Returns:
- Type
- void
off(eventName, handler, context) → {void}
Parameters:
Name | Type | Description |
---|---|---|
eventName |
||
handler |
||
context |
Returns:
- Type
- void
emit(eventName, args) → {void}
Parameters:
Name | Type | Description |
---|---|---|
eventName |
||
args |
Returns:
- Type
- void
enterRoom(params, scene) → {void}
Parameters:
Name | Type | Description |
---|---|---|
params |
TRTCParams | |
scene |
TRTCAppScene |
Returns:
- Type
- void
exitRoom() → {void}
Returns:
- Type
- void
switchRoom() → {void}
Returns:
- Type
- void
switchRole(role) → {void}
切换角色,仅适用于直播场景(TRTCAppSceneLIVE 和 TRTCAppSceneVoiceChatRoom)
Parameters:
Name | Type | Description |
---|---|---|
role |
TRTCRoleType |
Returns:
- Type
- void
startLocalPreview() → {Promise.<any>}
启动本地摄像头采集和预览
Returns:
- Type
- Promise.<any>
stopLocalPreview() → {void}
停止本地摄像头采集和预览
Returns:
- Type
- void
updateLocalView(view) → {void}
修改本地摄像头预览的 HTML 元素,小程序不支持
Parameters:
Name | Type | Description |
---|---|---|
view |
HTMLElement | null |
Returns:
- Type
- void
muteLocalVideo(mute, streamType) → {Promise.<void>}
暂停/恢复发布本地的视频流
Parameters:
Name | Type | Description |
---|---|---|
mute |
boolean |
true:屏蔽;false:开启,默认值:false |
streamType |
TRTCVideoStreamType |
要暂停/恢复的视频流类型, 仅支持 TRTCVideoStreamTypeBig 和 TRTCVideoStreamTypeSub |
Returns:
- Type
- Promise.<void>
startRemoteView(userId, view, streamType) → {void}
开始显示远端视频画面
Parameters:
Name | Type | Description |
---|---|---|
userId |
对方的用户标识 |
|
view |
此参数无效,小程序不支持 |
|
streamType |
视频流类型 |
Returns:
- Type
- void
stopRemoteView(userId, streamType) → {void}
停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
Parameters:
Name | Type | Description |
---|---|---|
userId |
对方的用户标识 |
|
streamType |
视频流类型 |
Returns:
- Type
- void
updateRemoteView(userId, view, streamType)
修改远端视频渲染的 HTML 元素,小程序不支持
Parameters:
Name | Type | Description |
---|---|---|
userId |
远端视频流的用户 ID |
|
view |
接受远端视频流渲染的 HTML 元素,传入 null 结束远端视频的渲染
|
|
streamType |
Returns:
switchCamera() → {Promise.<any>}
切换前后摄像头
Returns:
- Type
- Promise.<any>