2.7.2 • Published 7 days ago

@tencentcloud/tuiroom-engine-js v2.7.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 days ago

TUIRoomEngine Web SDK

简介

TUIRoomEngine Web SDK 依托腾讯云 实时音视频 TRTC即时通信 IM 服务,为用户提供房间管理,多人实时音视频互动,屏幕分享,成员管理,即时聊天等功能。

安装

// with npm
npm i @tencentcloud/tuiroom-engine-js --save

// with yarn
yarn add @tencentcloud/tuiroom-engine-js

// with pnpm
pnpm i @tencentcloud/tuiroom-engine-js --save

示例代码

import TUIRoomEngine from '@tencentcloud/tuiroom-engine-js';

let roomEngine = null;

// 错误
function onError(error) {
  console.error(error);
}

// 音量变化
function onUserVoiceVolumeChanged(eventInfo) {
  console.log(eventInfo.userVolumeList);
}

// 网络质量变化
function onUserNetworkQualityChanged(eventInfo) {
  console.log(eventInfo.userNetworkList);
}

// 被踢出房间
function onKickedOutOfRoom(eventInfo) {
  console.log(`roomId: ${eventInfo.roomId}, ${eventInfo.message}`);
}

// 用户签名 userSig 过期
function onUserSigExpired() {
  console.log('userSig expire');
}

// 被踢下线
function onKickedOffLine(eventInfo) {
  console.log(`user offline, reason: ${eventInfo.message}`);
}

// 设备变化:设备切换、设备插拔事件
function onDeviceChange(eventInfo) {
  console.log(`deviceChange ${JSON.stringify(eventInfo)}`);
}

async function init() {
  TUIRoomEngine.once('ready', () => {
    roomEngine = new TUIRoomEngine();
    roomEngine.on(TUIRoomEvents.onError, onError);
    roomEngine.on(TUIRoomEvents.onUserVoiceVolumeChanged, onUserVoiceVolumeChanged);
    roomEngine.on(TUIRoomEvents.onUserNetworkQualityChanged, onUserNetworkQualityChanged);
    roomEngine.on(TUIRoomEvents.onKickedOutOfRoom, onKickedOutOfRoom);
    roomEngine.on(TUIRoomEvents.onUserSigExpired, onUserSigExpired);
    roomEngine.on(TUIRoomEvents.onKickedOffLine, onKickedOffLine);
    roomEngine.on(TUIRoomEvents.onDeviceChange, onDeviceChange);
  });

  // sdkAppId 获取和 userSig 生成详见官网文档
  // https://cloud.tencent.com/document/product/647/81962#step1
  await TUIRoomEngine.login({ sdkAppId: 0, userId: '', userSig: '' });
  await TUIRoomEngine.setSelfInfo({ userName: 'zhangsan', avatarUrl: 'https://testurl' });
}

init();

API 列表

API含义
TUIRoomEngine.login登录 TUIRoomEngine
TUIRoomEngine.setSelfInfo设置当前用户基本信息(用户名、用户头像)
TUIRoomEngine.getSelfInfo获取当前用户信息
TUIRoomEngine.logout登出 TUIRoomEngine
roomEngine.createRoom创建房间
roomEngine.enterRoom进入房间
roomEngine.destroyRoom销毁房间
roomEngine.exitRoom离开房间
roomEngine.fetchRoomInfo获取房间信息
roomEngine.updateRoomNameByAdmin更新房间的名字(仅群主或者管理员可以调用)
roomEngine.updateRoomSeatModeByAdmin更新房间上麦模式(仅群主或者管理员可以调用)
roomEngine.getUserList获取当前房间用户列表
roomEngine.getUserInfo获取用户的详细信息
roomEngine.takeSeat获取麦位
roomEngine.setMaxSeatCount设置房间麦位最大值
roomEngine.leaveSeat释放麦位
roomEngine.lockSeatByAdmin锁定某个麦位状态
roomEngine.getSeatList获取麦位信息
roomEngine.openRemoteDeviceByAdmin请求远端用户打开摄像头
roomEngine.applyToAdminToOpenLocalDevice参会者向主持人申请打开设备
roomEngine.closeRemoteDeviceByAdmin关闭远端用户设备
roomEngine.takeUserOnSeatByAdmin邀请其他人上麦
roomEngine.kickUserOffSeatByAdmin要求其他人下麦
roomEngine.cancelRequest取消已经发出的请求
roomEngine.responseRemoteRequest回复远端用户的请求
roomEngine.setLocalVideoView设置本地流的渲染位置
roomEngine.openLocalCamera本地摄像头视频流采集
roomEngine.closeLocalCamera关闭本地摄像头
roomEngine.openLocalMicrophone打开本地麦克风
roomEngine.closeLocalMicrophone关闭本地麦克风
roomEngine.updateVideoQuality设置本地视频流的编码参数
roomEngine.updateAudioQuality设置本地音频的参数
roomEngine.startPushLocalVideo开始向远端推本地视频流
roomEngine.stopPushLocalVideo停止向远端推本地视频流
roomEngine.startPushLocalAudio开始向远端推本地音频流
roomEngine.stopPushLocalAudio停止向远端推本地音频流
roomEngine.setRemoteVideoView设置远端流渲染的区域
roomEngine.startPlayRemoteVideo开始播放远端用户视频流
roomEngine.stopPlayRemoteVideo停止播放远端用户视频流
roomEngine.muteRemoteAudioStream停止播放远端用户的音频流
roomEngine.changeUserRole改变用户的角色
roomEngine.kickRemoteUserOutOfRoom将用户踢出房间
roomEngine.disableDeviceForAllUserByAdmin所有用户的设备是否允许被使用
roomEngine.disableSendingMessageForAllUser所有用户的是否允许发消息
roomEngine.disableSendingMessageByAdmin特定用户是否被允许发消息
roomEngine.sendTextMessage发送文本消息,该接口自 v2.0.0 版本废弃
roomEngine.sendCustomMessage发送自定义消息,该接口自 v2.0.0 版本废弃
roomEngine.startScreenSharing开始屏幕共享
roomEngine.stopScreenSharing停止屏幕共享
roomEngine.on监听 roomEngine 的事件
roomEngine.off取消监听 roomEngine 的事件
roomEngine.getCameraDevicesList获取摄像头设备列表
roomEngine.getMicDevicesList获取麦克风设备列表
roomEngine.getSpeakerDevicesList获取扬声器设备列表
roomEngine.setCurrentCameraDevice设置要使用的摄像头设备
roomEngine.setCurrentMicDevice设置要使用的麦克风设备
roomEngine.setCurrentSpeakerDevice设置要使用的扬声器设备
roomEngine.getCurrentCameraDevice获取当前正在使用的摄像头设备
roomEngine.getCurrentMicDevice获取当前正在使用的麦克风设备
roomEngine.getCurrentSpeakerDevice获取当前正在使用的扬声器设备
roomEngine.startCameraDeviceTest开始进行摄像头测试
roomEngine.stopCameraDeviceTest停止摄像头测试
roomEngine.getTRTCCloud获取 trtcCloud 实例
roomEngine.getTIM获取 tim 实例

参考文档

2.7.2

7 days ago

2.7.1

11 days ago

2.7.0

22 days ago

2.6.7

1 month ago

2.6.3

2 months ago

2.6.2

2 months ago

2.5.2-beat.1

3 months ago

2.4.1

5 months ago

2.4.0

6 months ago

2.6.0

2 months ago

2.4.2

4 months ago

1.7.3-beta.2

5 months ago

1.7.3-beta.1

5 months ago

2.5.0

4 months ago

2.6.2-beta.1

2 months ago

2.6.2-beta.2

2 months ago

2.6.2-beta.3

2 months ago

2.4.1-beta.1

5 months ago

2.4.2-beta.1

5 months ago

2.3.3

6 months ago

2.3.2

7 months ago

2.3.1

7 months ago

2.2.4

7 months ago

2.2.3

7 months ago

2.2.2

8 months ago

2.2.1

8 months ago

2.2.0

8 months ago

2.1.0

9 months ago

2.0.3

10 months ago

2.0.2

10 months ago

1.7.2

10 months ago

2.0.1

10 months ago

2.0.0

11 months ago

1.7.1

11 months ago

1.7.1-beta.0

11 months ago

1.7.0

11 months ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.6.1

1 year ago

1.4.3

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.4.2

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.2-beta.1

1 year ago

1.3.2-beta.0

1 year ago

1.6.1-beta.0

1 year ago

1.4.0-beta.4

1 year ago

1.4.4-beta.0

1 year ago

1.3.1

1 year ago

1.4.0-beta.0

1 year ago

1.3.0

1 year ago

1.2.0

2 years ago

1.2.1

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.1-beta

2 years ago

1.0.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago