atomicx-core sdk API 文档
atomicx-core sdk
atomicx-core sdk 是腾讯云最新推出的面向即时通信、音视频通话、视频直播、语聊房等场景的全新一代基于响应式的 API,您可以非常快速的在基于这组 API 构建自己的 UI 页面,它支持房间管理、屏幕分享、成员管理、麦位控制、基础美颜等丰富功能,同时基于 TRTC SDK,能够提供超低延时、高品质的音视频体验,本页面包含 atomicx-core sdk 的所有API接口,按功能模块分类展示。
LoginState
用户身份认证与登录管理模块
响应式数据
loginUserInfo
Ref
示例
import { useLoginState } from '@/uni_modules/tuikit-atomic-x/state/LoginState';
const { loginUserInfo } = useLoginState();
// 监听用户信息变化
watch(loginUserInfo, (newUserInfo) => {
if (newUserInfo) {
console.log('用户信息更新:', newUserInfo);
console.log('用户ID:', newUserInfo.userID);
console.log('用户昵称:', newUserInfo.nickname);
console.log('用户头像:', newUserInfo.avatarURL);
}
});
// 获取当前用户信息
const currentUser = loginUserInfo.value;
if (currentUser) {
console.log('当前登录用户:', currentUser.nickname);
}
loginStatus
Ref
示例
import { useLoginState } from '@/uni_modules/tuikit-atomic-x/state/LoginState';
const { logout } = useLoginState();
logout({
onSuccess: () => console.log('登出成功'),
onError: (error) => console.error('登出失败:', error)
});
接口函数
login
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | LoginOptions | 登录参数 |
示例
import { useLoginState } from '@/uni_modules/tuikit-atomic-x/state/LoginState';
const { login } = useLoginState();
login({
sdkAppID: 1400000000,
userID: 'user123',
userSig: 'eJx1kF1PwzAMhv9KlG...',
onSuccess: () => console.log('登录成功'),
onError: (error) => console.error('登录失败:', error)
});
logout
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| [params] | LogoutOptions | 登出参数(可选) |
示例
import { useLoginState } from '@/uni_modules/tuikit-atomic-x/state/LoginState';
const { logout } = useLoginState();
logout({
onSuccess: () => console.log('登出成功'),
onError: (error) => console.error('登出失败:', error)
});
setSelfInfo
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| userInfo | SetSelfInfoOptions | 用户信息 |
示例
import { useLoginState } from '@/uni_modules/tuikit-atomic-x/state/LoginState';
const { setSelfInfo } = useLoginState();
setSelfInfo({
userID: 'user123',
nickname: '张三',
avatarURL: 'https://example.com/avatar.jpg',
onSuccess: () => console.log('用户信息设置成功'),
onError: (error) => console.error('用户信息设置失败:', error)
});
LiveListState
直播列表管理模块
核心功能:管理直播间的完整生命周期,包括创建、加入、离开、结束等核心业务流程。
技术特点:支持分页加载、实时状态同步、直播信息动态更新,采用响应式数据管理,确保UI与数据状态实时同步。
业务价值:为直播平台提供核心的直播间管理能力,支持大规模并发直播场景,是直播业务的基础设施。
应用场景:直播列表展示、直播间创建、直播状态管理、直播数据统计等核心业务场景。
响应式数据
liveList
Ref
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { liveList } = useLiveState();
// 监听直播列表变化
watch(liveList, (newList) => {
if (newList && newList.length > 0) {
console.log('直播列表更新:', newList);
newList.forEach(live => {
console.log('直播ID:', live.liveID);
console.log('直播标题:', live.title);
console.log('主播用户ID:', live.ownerUserID);
});
}
});
// 获取当前直播列表
const currentList = liveList.value;
console.log('当前直播数量:', currentList.length);
liveListCursor
Ref
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { liveListCursor } = useLiveState();
// 监听游标变化用于分页加载
watch(liveListCursor, (newCursor) => {
console.log('直播列表游标更新:', newCursor);
// 当游标更新时,可以获取下一页数据
if (newCursor) {
console.log('加载下一页直播列表');
}
});
// 获取当前游标
const cursor = liveListCursor.value;
if (cursor) {
console.log('当前分页游标:', cursor);
}
currentLive
Ref
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { currentLive } = useLiveState();
// 监听当前直播信息变化
watch(currentLive, (newLive) => {
if (newLive) {
console.log('当前直播信息更新:', newLive);
console.log('直播ID:', newLive.liveID);
console.log('直播标题:', newLive.title);
console.log('观看人数:', newLive.viewerCount);
}
});
// 获取当前直播信息
const live = currentLive.value;
if (live) {
console.log('当前进入的直播:', live.title);
}
接口函数
fetchLiveList
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | FetchLiveListOptions | 获取参数 |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { fetchLiveList } = useLiveState();
fetchLiveList({ cursor: "", count: 20 });
createLive
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | CreateLiveOptions | 创建参数 |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { createLive } = useLiveState();
createLive({ title: 'my live', coverUrl: 'https://example.com/cover.jpg'});
joinLive
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | JoinLiveOptions | 加入参数 |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { joinLive } = useLiveState();
joinLive({ liveID: 'host_live_id' });
leaveLive
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| [params] | LeaveLiveOptions | 离开参数(可选) |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { leaveLive } = useLiveState();
leaveLive();
endLive
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| [params] | EndLiveOptions | 结束参数(可选) |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { endLive } = useLiveState();
endLive();
updateLiveInfo
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | UpdateLiveInfoOptions | 更新参数 |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { updateLiveInfo } = useLiveState();
updateLiveInfo({ liveID: 'your_live_id', title: 'new title' });
addLiveListListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| eventName | string | 事件名称,可选值: 'onLiveEnded'(直播结束) 'onKickedOutOfLive'(被踢出直播间) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { addLiveListListener } = useLiveState();
addLiveListListener('onLiveEnded', {
callback: (params) => {
console.log('result:', params);
}
});
removeLiveListListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| eventName | string | 事件名称,可选值: 'onLiveEnded'(直播结束) 'onKickedOutOfLive'(被踢出直播间) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useLiveState } from '@/uni_modules/tuikit-atomic-x/state/LiveListState';
const { removeLiveListListener } = useLiveState();
removeLiveListListener('onLiveEnded', liveEndedListener);
LiveSeatState
直播间座位管理模块
核心功能:实现多人连麦场景下的座位控制,支持复杂的座位状态管理和音视频设备控制。
技术特点:基于WebRTC技术,支持多路音视频流管理,提供座位锁定、设备控制、权限管理等高级功能。
业务价值:为多人互动直播提供核心技术支撑,支持PK、连麦、多人游戏等丰富的互动场景。
应用场景:多人连麦、主播PK、互动游戏、在线教育、会议直播等需要多人音视频互动的场景。
响应式数据
seatList
Ref
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { seatList } = useLiveSeatState('your_live_id');
// 监听座位列表变化
watch(seatList, (newSeatList) => {
if (newSeatList && newSeatList.length > 0) {
console.log('座位列表更新:', newSeatList);
newSeatList.forEach(seat => {
console.log('座位索引:', seat.index);
console.log('座位是否锁定:', seat.isLocked);
if (seat.userInfo) {
console.log('座位上用户ID:', seat.userInfo.userID);
}
});
}
});
// 获取当前座位列表
const seats = seatList.value;
console.log('当前座位数量:', seats.length);
canvas
Ref
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { canvas } = useLiveSeatState('your_live_id');
// 监听画布信息变化
watch(canvas, (newCanvas) => {
if (newCanvas) {
console.log('画布信息更新:', newCanvas);
console.log('画布宽度:', newCanvas.w);
console.log('画布高度:', newCanvas.h);
if (newCanvas.background) {
console.log('画布背景色:', newCanvas.background);
}
}
});
// 获取当前画布信息
const currentCanvas = canvas.value;
if (currentCanvas) {
console.log('当前画布分辨率:', currentCanvas.w, 'x', currentCanvas.h);
}
speakingUsers
Ref
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { speakingUsers } = useLiveSeatState('your_live_id');
// 监听正在说话的用户列表变化
watch(speakingUsers, (newSpeakingUsers) => {
if (newSpeakingUsers && newSpeakingUsers.size > 0) {
console.log('正在说话的用户更新');
newSpeakingUsers.forEach((volume, userID) => {
console.log('用户ID:', userID);
console.log('音量:', volume);
});
}
});
// 获取当前正在说话的用户数量
const users = speakingUsers.value;
if (users) {
console.log('当前说话的用户数:', users.size);
}
接口函数
takeSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | TakeSeatOptions | 上麦参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { takeSeat } = useLiveSeatState('your_live_id');
takeSeat({
seatIndex: 1,
onSuccess: () => console.log('上麦成功'),
onError: (error) => console.error('上麦失败:', error)
});
leaveSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | LeaveSeatOptions | 下麦参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { leaveSeat } = useLiveSeatState('your_live_id');
leaveSeat({
onSuccess: () => console.log('下麦成功'),
onError: (error) => console.error('下麦失败:', error)
});
muteMicrophone
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | MuteMicrophoneOptions | 静音参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { muteMicrophone } = useLiveSeatState('your_live_id');
muteMicrophone({
onSuccess: () => console.log('麦克风静音成功'),
onError: (error) => console.error('麦克风静音失败:', error)
});
unmuteMicrophone
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | UnmuteMicrophoneOptions | 取消静音参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { unmuteMicrophone } = useLiveSeatState('your_live_id');
unmuteMicrophone({
onSuccess: () => console.log('麦克风取消静音成功'),
onError: (error) => console.error('麦克风取消静音失败:', error)
});
kickUserOutOfSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | KickUserOutOfSeatOptions | 踢出参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { kickUserOutOfSeat } = useLiveSeatState('your_live_id');
kickUserOutOfSeat({
seatIndex: 1,
onSuccess: () => console.log('踢出用户成功'),
onError: (error) => console.error('踢出用户失败:', error)
});
moveUserToSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | MoveUserToSeatOptions | 移动参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { moveUserToSeat } = useLiveSeatState('your_live_id');
moveUserToSeat({
fromSeatIndex: 1,
toSeatIndex: 3,
onSuccess: () => console.log('用户移动成功'),
onError: (error) => console.error('用户移动失败:', error)
});
lockSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | LockSeatOptions | 锁定参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { lockSeat } = useLiveSeatState('your_live_id');
lockSeat({
seatIndex: 2,
onSuccess: () => console.log('座位锁定成功'),
onError: (error) => console.error('座位锁定失败:', error)
});
unlockSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | UnlockSeatOptions | 解锁参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { unlockSeat } = useLiveSeatState('your_live_id');
unlockSeat({
seatIndex: 2,
onSuccess: () => console.log('座位解锁成功'),
onError: (error) => console.error('座位解锁失败:', error)
});
openRemoteCamera
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | OpenRemoteCameraOptions | 开启摄像头参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { openRemoteCamera } = useLiveSeatState('your_live_id');
openRemoteCamera({
seatIndex: 1,
onSuccess: () => console.log('远程摄像头开启成功'),
onError: (error) => console.error('远程摄像头开启失败:', error)
});
closeRemoteCamera
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | CloseRemoteCameraOptions | 关闭摄像头参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { closeRemoteCamera } = useLiveSeatState('your_live_id');
closeRemoteCamera({
seatIndex: 1,
onSuccess: () => console.log('远程摄像头关闭成功'),
onError: (error) => console.error('远程摄像头关闭失败:', error)
});
openRemoteMicrophone
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | OpenRemoteMicrophoneOptions | 开启麦克风参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { openRemoteMicrophone } = useLiveSeatState('your_live_id');
openRemoteMicrophone({
seatIndex: 1,
onSuccess: () => console.log('远程麦克风开启成功'),
onError: (error) => console.error('远程麦克风开启失败:', error)
});
closeRemoteMicrophone
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | CloseRemoteMicrophoneOptions | 关闭麦克风参数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { closeRemoteMicrophone } = useLiveSeatState('your_live_id');
closeRemoteMicrophone({
seatIndex: 1,
onSuccess: () => console.log('远程麦克风关闭成功'),
onError: (error) => console.error('远程麦克风关闭失败:', error)
});
addLiveSeatEventListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onLocalCameraOpenedByAdmin'(本地摄像头被管理员开启) 'onLocalCameraClosedByAdmin'(本地摄像头被管理员关闭) 'onLocalMicrophoneOpenedByAdmin'(本地麦克风被管理员开启) 'onLocalMicrophoneClosedByAdmin'(本地麦克风被管理员关闭) |
| listener | ILiveListener | 事件处理函数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { addLiveSeatEventListener } = useLiveSeatState('your_live_id');
addLiveSeatEventListener('your_live_id', 'onLocalCameraOpenedByAdmin', {
callback: (params) => {
console.log('result:', params);
}
});
removeLiveSeatEventListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onLocalCameraOpenedByAdmin'(本地摄像头被管理员开启) 'onLocalCameraClosedByAdmin'(本地摄像头被管理员关闭) 'onLocalMicrophoneOpenedByAdmin'(本地麦克风被管理员开启) 'onLocalMicrophoneClosedByAdmin'(本地麦克风被管理员关闭) |
| listener | ILiveListener | 事件处理函数 |
示例
import { useLiveSeatState } from '@/uni_modules/tuikit-atomic-x/state/LiveSeatState';
const { removeLiveSeatEventListener } = useLiveSeatState('your_live_id');
removeLiveSeatEventListener('your_live_id', 'onLocalCameraOpenedByAdmin', seatListener);
LiveAudienceState
直播间观众管理模块
核心功能:管理直播间观众列表,提供观众权限控制、管理员设置等直播间秩序维护功能。
技术特点:支持实时观众列表更新、权限分级管理、批量操作等高级功能,确保直播间秩序和用户体验。
业务价值:为直播平台提供完整的观众管理解决方案,支持大规模观众场景下的秩序维护。
应用场景:观众管理、权限控制、直播间秩序维护、观众互动管理等核心业务场景。
响应式数据
audienceList
Ref
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { audienceList } = useLiveAudienceState('your_live_id');
// 监听观众列表变化
watch(audienceList, (newAudienceList) => {
if (newAudienceList && newAudienceList.length > 0) {
console.log('观众列表更新:', newAudienceList);
newAudienceList.forEach(audience => {
console.log('观众ID:', audience.userID);
console.log('观众昵称:', audience.nickname);
console.log('观众角色:', audience.role);
});
}
});
// 获取当前观众列表
const audiences = audienceList.value;
console.log('当前观众列表:', audiences);
audienceCount
Ref
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { audienceCount } = useLiveAudienceState('your_live_id');
// 监听观众数量变化
watch(audienceCount, (newCount) => {
console.log('观众数量更新:', newCount);
// 当观众数量达到某个阈值时可以进行特殊处理
if (newCount >= 100) {
console.log('直播热度很高,观众数超过100');
}
});
// 获取当前观众数量
const count = audienceCount.value;
console.log('当前观众数量:', count);
接口函数
fetchAudienceList
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| [params] | FetchAudienceListOptions | 获取观众列表参数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { fetchAudienceList } = useLiveAudienceState("your_live_id");
fetchAudienceList();
setAdministrator
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetAdministratorOptions | 设置管理员参数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { setAdministrator } = useLiveAudienceState("your_live_id");
setAdministrator({ userID: 'user123' });
revokeAdministrator
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | RevokeAdministratorOptions | 撤销管理员参数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { revokeAdministrator } = useLiveAudienceState("your_live_id");
revokeAdministrator({ userID: 'user123' });
kickUserOutOfRoom
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | KickUserOutOfRoomOptions | 踢出用户参数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { kickUserOutOfRoom } = useLiveAudienceState("your_live_id");
kickUserOutOfRoom({ userID: 'user123' });
disableSendMessage
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | DisableSendMessageOptions | 禁用发送消息参数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { disableSendMessage } = useLiveAudienceState("your_live_id");
disableSendMessage({ userID: 'user123', disable: true });
addAudienceListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onAudienceJoined'(观众加入) 'onAudienceLeft'(观众离开) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { addAudienceListener } = useLiveAudienceState("your_live_id");
addAudienceListener('your_live_id', 'onAudienceJoined', {
callback: (params) => {
console.log('result:', params);
}
});
removeAudienceListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onAudienceJoined'(观众加入) 'onAudienceLeft'(观众离开) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useLiveAudienceState } from '@/uni_modules/tuikit-atomic-x/state/LiveAudienceState';
const { removeAudienceListener } = useLiveAudienceState("your_live_id");
removeAudienceListener('your_live_id', 'onAudienceJoined', audienceListener);
CoGuestState
连麦嘉宾管理模块
核心功能:处理观众与主播之间的连麦互动,管理连麦申请、邀请、接受、拒绝等完整的连麦流程。
技术特点:基于实时音视频技术,支持连麦状态实时同步、音视频质量自适应、网络状况监控等高级功能。
业务价值:为直播平台提供观众参与互动的核心能力,增强用户粘性和直播趣味性。
应用场景:观众连麦、互动问答、在线K歌、游戏直播等需要观众参与的互动场景。
响应式数据
connected
Ref
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { connected } = useCoGuestState('your_live_id');
// 监听已连接的连麦嘉宾列表变化
watch(connected, (newConnected) => {
if (newConnected && newConnected.length > 0) {
console.log('连麦嘉宾列表更新:', newConnected);
newConnected.forEach(guest => {
console.log('嘉宾用户ID:', guest.userID);
console.log('嘉宾昵称:', guest.nickname);
});
}
});
// 获取当前连麦嘉宾列表
const guests = connected.value;
console.log('当前连麦嘉宾数量:', guests.length);
invitees
Ref
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { invitees } = useCoGuestState('your_live_id');
// 监听被邀请用户列表变化
watch(invitees, (newInvitees) => {
if (newInvitees && newInvitees.length > 0) {
console.log('被邀请用户列表更新:', newInvitees);
newInvitees.forEach(user => {
console.log('被邀请用户ID:', user.userID);
console.log('被邀请用户昵称:', user.nickname);
});
}
});
// 获取当前被邀请用户列表
const invitedUsers = invitees.value;
console.log('当前被邀请用户数量:', invitedUsers.length);
applicants
Ref
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { applicants } = useCoGuestState('your_live_id');
// 监听申请上麦用户列表变化
watch(applicants, (newApplicants) => {
if (newApplicants && newApplicants.length > 0) {
console.log('申请上麦用户列表更新:', newApplicants);
newApplicants.forEach(user => {
console.log('申请用户ID:', user.userID);
console.log('申请用户昵称:', user.nickname);
});
}
});
// 获取当前申请上麦用户列表
const applyingUsers = applicants.value;
console.log('当前申请用户数量:', applyingUsers.length);
candidates
Ref
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { candidates } = useCoGuestState('your_live_id');
// 监听候选用户列表变化
watch(candidates, (newCandidates) => {
if (newCandidates && newCandidates.length > 0) {
console.log('候选用户列表更新:', newCandidates);
newCandidates.forEach(user => {
console.log('候选用户ID:', user.userID);
console.log('候选用户昵称:', user.nickname);
});
}
});
// 获取当前候选用户列表
const candidateUsers = candidates.value;
console.log('当前候选用户数量:', candidateUsers.length);
接口函数
applyForSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | ApplyForSeatOptions | 申请连麦座位参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { applyForSeat } = useCoGuestState("your_live_id");
applyForSeat({ seatIndex: 2, timeout: 30 , extension: 'extra info'});
cancelApplication
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | CancelApplicationOptions | 取消申请参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { cancelApplication } = useCoGuestState("your_live_id");
cancelApplication({});
acceptApplication
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | AcceptApplicationOptions | 接受申请参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { acceptApplication } = useCoGuestState("your_live_id");
acceptApplication({ userID: 'user123', seatIndex: 0 });
rejectApplication
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | RejectApplicationOptions | 拒绝申请参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { rejectApplication } = useCoGuestState("your_live_id");
rejectApplication({ userID: 'user123' });
inviteToSeat
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | InviteToSeatOptions | 邀请上麦参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { inviteToSeat } = useCoGuestState("your_live_id");
inviteToSeat({ userID: 'user123', seatIndex: 2, timeout: 30 , extension: 'extra info'});
cancelInvitation
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | CancelInvitationOptions | 取消邀请参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { cancelInvitation } = useCoGuestState("your_live_id");
cancelInvitation({ inviteeID: 'user123' });
acceptInvitation
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | AcceptInvitationOptions | 接受邀请参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { acceptInvitation } = useCoGuestState("your_live_id");
acceptInvitation({ inviterID: 'user123' });
rejectInvitation
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | RejectInvitationOptions | 拒绝邀请参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { rejectInvitation } = useCoGuestState("your_live_id");
rejectInvitation({ inviterID: 'user123'});
disconnect
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | DisconnectOptions | 断开连接参数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { disconnect } = useCoGuestState("your_live_id");
disconnect();
addCoGuestGuestListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onHostInvitationReceived'(收到主播邀请) 'onHostInvitationCancelled'(主播取消邀请) 'onGuestApplicationResponded'(嘉宾申请响应) 'onGuestApplicationNoResponse'(嘉宾申请无响应) 'onKickedOffSeat'(被踢下座位) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { addCoGuestGuestListener } = useCoGuestState("your_live_id");
addCoGuestGuestListener('your_live_id', 'onHostInvitationReceived', {
callback: (params) => {
console.log('result:', params);
}
});
removeCoGuestGuestListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onHostInvitationReceived'(收到主播邀请) 'onHostInvitationCancelled'(主播取消邀请) 'onGuestApplicationResponded'(嘉宾申请响应) 'onGuestApplicationNoResponse'(嘉宾申请无响应) 'onKickedOffSeat'(被踢下座位) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { removeCoGuestGuestListener } = useCoGuestState("your_live_id");
removeCoGuestGuestListener('your_live_id', 'onHostInvitationReceived', guestListener);
addCoGuestHostListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onGuestApplicationReceived'(收到嘉宾申请) 'onGuestApplicationCancelled'(嘉宾取消申请) 'onGuestApplicationProcessedByOtherHost'(嘉宾申请被其他主播处理) 'onHostInvitationResponded'(主播邀请得到回应) 'onHostInvitationNoResponse'(主播邀请无响应) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { addCoGuestHostListener } = useCoGuestState("your_live_id");
addCoGuestHostListener('your_live_id', 'onGuestApplicationReceived', {
callback: (params) => {
console.log('result:', params);
}
});
removeCoGuestHostListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onGuestApplicationReceived'(收到嘉宾申请) 'onGuestApplicationCancelled'(嘉宾取消申请) 'onGuestApplicationProcessedByOtherHost'(嘉宾申请被其他主播处理) 'onHostInvitationResponded'(主播邀请得到回应) 'onHostInvitationNoResponse'(主播邀请无响应) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useCoGuestState } from '@/uni_modules/tuikit-atomic-x/state/CoGuestState';
const { removeCoGuestHostListener } = useCoGuestState("your_live_id");
removeCoGuestHostListener('your_live_id', 'onGuestApplicationReceived', hostListener);
CoHostState
连麦主播管理模块
核心功能:实现主播间的连麦功能,支持主播邀请、连麦申请、连麦状态管理等主播间互动功能。
技术特点:支持多主播音视频同步、画中画显示、音视频质量优化等高级技术,确保连麦体验的流畅性。
业务价值:为直播平台提供主播间协作的核心能力,支持PK、合作直播等高级业务场景。
应用场景:主播PK、合作直播、跨平台连麦、主播互动等高级直播场景。
响应式数据
connected
Ref
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { connected } = useCoHostState('your_live_id');
// 监听已连接的连线主播列表变化
watch(connected, (newConnected) => {
if (newConnected && newConnected.length > 0) {
console.log('已连接的主播列表:', newConnected);
}
});
// 获取当前已连接的连线主播数量
const coHosts = connected.value;
console.log('已连接的主播数:', coHosts.length);
invitees
Ref
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { invitees } = useCoHostState('your_live_id');
// 监听被邀请的主播列表变化
watch(invitees, (newInvitees) => {
if (newInvitees && newInvitees.length > 0) {
console.log('被邀请的主播列表:', newInvitees);
}
});
// 获取当前被邀请的主播列表
const invitedHosts = invitees.value;
console.log('被邀请的主播数:', invitedHosts.length);
applicant
Ref
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { applicant } = useCoHostState('your_live_id');
// 监听申请连线的主播信息变化
watch(applicant, (newApplicant) => {
if (newApplicant) {
console.log('申请主播:', newApplicant);
console.log('主播ID:', newApplicant.userID);
}
});
// 获取当前申请连线的主播信息
const currentApplicant = applicant.value;
if (currentApplicant) {
console.log('当前申请连线的主播:', currentApplicant.nickname);
}
candidates
Ref
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { candidates } = useCoHostState('your_live_id');
// 监听候选主播列表变化
watch(candidates, (newCandidates) => {
if (newCandidates && newCandidates.length > 0) {
console.log('候选主播列表:', newCandidates);
}
});
// 获取当前候选主播列表
const candidateHosts = candidates.value;
console.log('候选主播数:', candidateHosts.length);
coHostStatus
Ref
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { coHostStatus } = useCoHostState('your_live_id');
// 监听连线状态变化
watch(coHostStatus, (newStatus) => {
console.log('连线状态:', newStatus);
});
// 获取当前连线状态
const status = coHostStatus.value;
console.log('当前连线状态:', status);
接口函数
requestHostConnection
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | RequestHostConnectionOptions | 请求连线参数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { requestHostConnection } = useCoHostState("your_live_id");
requestHostConnection({});
cancelHostConnection
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | CancelHostConnectionOptions | 取消连线请求参数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { cancelHostConnection } = useCoHostState(“your_live_id”);
cancelHostConnection({ toHostLiveID : "target_live_id" });
acceptHostConnection
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | AcceptHostConnectionOptions | 接受连线请求参数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { acceptHostConnection } = useCoHostState(“your_live_id”);
acceptHostConnection({ fromHostLiveID: "from_live_id" });
rejectHostConnection
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | RejectHostConnectionOptions | 拒绝连线请求参数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { rejectHostConnection } = useCoHostState(“your_live_id”);
rejectHostConnection({ fromHostLiveID: "from_live_id" });
exitHostConnection
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | ExitHostConnectionOptions | 退出连线参数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { exitHostConnection } = useCoHostState(“your_live_id”);
exitHostConnection({});
addCoHostListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onCoHostRequestReceived'(收到连线请求) 'onCoHostRequestCancelled'(连线请求被取消) 'onCoHostRequestAccepted'(连线请求被接受) 'onCoHostRequestRejected'(连线请求被拒绝) 'onCoHostRequestTimeout'(连线请求超时) 'onCoHostUserJoined'(连线用户加入) 'onCoHostUserLeft'(连线用户离开) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { addCoHostListener } = useCoHostState("your_live_id");
addCoHostListener('your_live_id', 'onCoHostRequestReceived', {
callback: (params) => {
console.log('result:', params);
}
});
removeCoHostListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onCoHostRequestReceived'(收到连线请求) 'onCoHostRequestCancelled'(连线请求被取消) 'onCoHostRequestAccepted'(连线请求被接受) 'onCoHostRequestRejected'(连线请求被拒绝) 'onCoHostRequestTimeout'(连线请求超时) 'onCoHostUserJoined'(连线用户加入) 'onCoHostUserLeft'(连线用户离开) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useCoHostState } from '@/uni_modules/tuikit-atomic-x/state/CoHostState';
const { removeCoHostListener } = useCoHostState("your_live_id");
removeCoHostListener('your_live_id', 'onCoHostRequestReceived', hostListener);
DeviceState
设备状态管理模块
核心功能:管理摄像头、麦克风等音视频设备的控制,提供设备状态监控、权限检查等基础设备服务。
技术特点:支持多设备管理、设备状态实时监控、权限动态检查、设备故障自动恢复等高级功能。
业务价值:为直播系统提供稳定的设备基础,确保音视频采集的可靠性和用户体验。
应用场景:设备管理、权限控制、音视频采集、设备故障处理等基础技术场景。
响应式数据
microphoneStatus
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { microphoneStatus } = useDeviceState();
// 监听麦克风状态变化
watch(microphoneStatus, (newStatus) => {
console.log('麦克风状态:', newStatus);
if (newStatus === 'ON') {
console.log('麦克风已打开');
} else if (newStatus === 'OFF') {
console.log('麦克风已关闭');
}
});
microphoneLastError
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { microphoneLastError } = useDeviceState();
// 监听麦克风错误状态
watch(microphoneLastError, (newError) => {
if (newError && newError !== 'NO_ERROR') {
console.log('麦克风错误:', newError);
}
});
hasPublishAudioPermission
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { hasPublishAudioPermission } = useDeviceState();
// 检查是否有音频发布权限
const hasPermission = hasPublishAudioPermission.value;
if (!hasPermission) {
console.log('没有音频发布权限');
}
captureVolume
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { captureVolume } = useDeviceState();
// 监听采集音量变化
watch(captureVolume, (newVolume) => {
console.log('采集音量:', newVolume);
});
currentMicVolume
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { currentMicVolume } = useDeviceState();
// 监听麦克风音量变化
watch(currentMicVolume, (newVolume) => {
console.log('当前麦克风音量:', newVolume);
});
outputVolume
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { outputVolume } = useDeviceState();
// 监听输出音量变化
watch(outputVolume, (newVolume) => {
console.log('输出音量:', newVolume);
});
cameraStatus
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { cameraStatus } = useDeviceState();
// 监听摄像头状态变化
watch(cameraStatus, (newStatus) => {
console.log('摄像头状态:', newStatus);
if (newStatus === 'ON') {
console.log('摄像头已打开');
}
});
cameraLastError
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { cameraLastError } = useDeviceState();
// 监听摄像头错误状态
watch(cameraLastError, (newError) => {
if (newError && newError !== 'NO_ERROR') {
console.log('摄像头错误:', newError);
}
});
isFrontCamera
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { isFrontCamera } = useDeviceState();
// 检查当前是否为前置摄像头
const isFront = isFrontCamera.value;
if (isFront) {
console.log('当前使用前置摄像头');
}
localMirrorType
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { localMirrorType } = useDeviceState();
// 获取本地镜像类型
const mirrorType = localMirrorType.value;
console.log('本地镜像类型:', mirrorType);
localVideoQuality
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { localVideoQuality } = useDeviceState();
// 获取本地视频质量设置
const quality = localVideoQuality.value;
console.log('本地视频质量:', quality);
currentAudioRoute
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { currentAudioRoute } = useDeviceState();
// 监听音频输出路由变化
watch(currentAudioRoute, (newRoute) => {
console.log('音频输出路由:', newRoute);
if (newRoute === 'SPEAKERPHONE') {
console.log('使用扬声器');
} else if (newRoute === 'EARPIECE') {
console.log('使用耳机');
}
});
screenStatus
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { screenStatus } = useDeviceState();
// 监听屏幕共享状态
watch(screenStatus, (newStatus) => {
console.log('屏幕共享状态:', newStatus);
if (newStatus === 'ON') {
console.log('屏幕共享已开启');
}
});
networkInfo
Ref
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { networkInfo } = useDeviceState();
// 获取网络信息
const info = networkInfo.value;
console.log('网络信息:', info);
接口函数
openLocalMicrophone
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| [params] | OpenLocalMicrophoneOptions | 麦克风参数 |
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { openLocalMicrophone } = useDeviceState();
openLocalMicrophone({})
closeLocalMicrophone
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { closeLocalMicrophone } = useDeviceState();
closeLocalMicrophone()
setCaptureVolume
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | VolumeOptions | 音量参数 |
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { setCaptureVolume } = useDeviceState();
setCaptureVolume({ volume: 80 })
setOutputVolume
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | VolumeOptions | 音量参数 |
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { setOutputVolume } = useDeviceState();
setOutputVolume({ volume: 90 })
setAudioRoute
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetAudioRouteOptions | 音频路由参数 |
示例
// 设置为扬声器
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { setAudioRoute } = useDeviceState();
setAudioRoute({ route: 'SPEAKERPHONE' })
openLocalCamera
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| [params] | OpenLocalCameraOptions | 摄像头参数 |
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { openLocalCamera } = useDeviceState();
openLocalCamera({ isFront: true })
closeLocalCamera
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { closeLocalCamera } = useDeviceState();
closeLocalCamera()
switchCamera
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SwitchCameraOptions | 切换参数 |
示例
// 切换到前置摄像头
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { switchCamera } = useDeviceState();
switchCamera({ isFront: true })
switchMirror
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SwitchMirrorOptions | 镜像参数 |
示例
// 设置自动镜像
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { switchMirror } = useDeviceState();
switchMirror({ mirrorType: 'AUTO' })
updateVideoQuality
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | UpdateVideoQualityOptions | 视频质量参数 |
示例
import { useDeviceState } from '@/uni_modules/tuikit-atomic-x/state/DeviceState';
const { updateVideoQuality } = useDeviceState();
updateVideoQuality({ quality: 'VIDEOQUALITY_1080P' })
AudioEffectState
音效处理模块
核心功能:提供变声、混响、耳返等高级音效功能,支持多种音效效果和实时音效调节。
技术特点:基于腾讯天籁实验室的音频处理算法,支持实时音效处理、低延迟音频传输、音质优化等高级技术。
业务价值:为直播平台提供差异化的音效体验,增强用户参与度和直播趣味性。
应用场景:变声直播、K歌直播、音效娱乐、专业音效等需要音频处理的场景。
响应式数据
isEarMonitorOpened
Ref
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { isEarMonitorOpened } = useAudioEffectState('your_live_id');
// 监听耳返开关状态变化
watch(isEarMonitorOpened, (newStatus) => {
console.log('耳返开关状态:', newStatus);
if (newStatus) {
console.log('耳返已打开');
} else {
console.log('耳返已关闭');
}
});
// 获取当前耳返开关状态
const isOpen = isEarMonitorOpened.value;
console.log('当前耳返状态:', isOpen);
earMonitorVolume
Ref
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { earMonitorVolume } = useAudioEffectState('your_live_id');
// 监听耳返音量变化
watch(earMonitorVolume, (newVolume) => {
console.log('耳返音量:', newVolume);
});
// 获取当前耳返音量
const volume = earMonitorVolume.value;
console.log('当前耳返音量:', volume);
audioChangerType
Ref
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { audioChangerType } = useAudioEffectState('your_live_id');
// 监听变声类型变化
watch(audioChangerType, (newType) => {
console.log('变声类型:', newType);
});
// 获取当前变声类型
const type = audioChangerType.value;
console.log('当前变声类型:', type);
audioReverbType
Ref
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { audioReverbType } = useAudioEffectState('your_live_id');
// 监听混响类型变化
watch(audioReverbType, (newType) => {
console.log('混响类型:', newType);
});
// 获取当前混响类型
const type = audioReverbType.value;
console.log('当前混响类型:', type);
接口函数
setAudioChangerType
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetAudioChangerTypeOptions | 变声效果参数 |
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { setAudioChangerType } = useAudioEffectState("your_live_id");
setAudioChangerType({ changerType: 'MAN' });
setAudioReverbType
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetAudioReverbTypeOptions | 混响效果参数 |
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { setAudioReverbType } = useAudioEffectState("your_live_id");
setAudioReverbType({ reverbType: 'KTV' });
setVoiceEarMonitorEnable
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetVoiceEarMonitorEnableOptions | 耳返开关参数 |
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { setVoiceEarMonitorEnable } = useAudioEffectState("your_live_id");
setVoiceEarMonitorEnable({ enable: true });
setVoiceEarMonitorVolume
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | VolumeOptions | 耳返音量参数 |
示例
import { useAudioEffectState } from '@/uni_modules/tuikit-atomic-x/state/AudioEffectState';
const { setVoiceEarMonitorVolume } = useAudioEffectState("your_live_id");
setVoiceEarMonitorVolume({ volume: 50 });
BarrageState
弹幕消息管理模块
核心功能:处理直播间内的文本消息、自定义消息等弹幕功能,支持弹幕发送、消息状态同步等完整弹幕系统。
技术特点:支持高并发消息处理、实时消息同步、消息过滤、表情包支持等高级功能。
业务价值:为直播平台提供核心的互动能力,增强用户参与度和直播氛围。
应用场景:弹幕互动、消息管理、表情包、聊天室等社交互动场景。
响应式数据
messageList
Ref
示例
import { useBarrageState } from '@/uni_modules/tuikit-atomic-x/state/BarrageState';
const { messageList } = useBarrageState('your_live_id');
// 监听弹幕消息列表变化
watch(messageList, (newMessages) => {
if (newMessages && newMessages.length > 0) {
console.log('弹幕消息列表更新:', newMessages);
newMessages.forEach(msg => {
console.log('消息内容:', msg.content);
console.log('发送者:', msg.sender);
});
}
});
// 获取当前弹幕列表
const messages = messageList.value;
console.log('当前弹幕数量:', messages.length);
allowSendMessage
Ref
示例
import { useBarrageState } from '@/uni_modules/tuikit-atomic-x/state/BarrageState';
const { allowSendMessage } = useBarrageState('your_live_id');
// 监听消息发送权限变化
watch(allowSendMessage, (newAllow) => {
console.log('是否允许发送消息:', newAllow);
if (newAllow) {
console.log('可以发送消息');
} else {
console.log('不可以发送消息');
}
});
// 检查当前是否允许发送消息
const canSend = allowSendMessage.value;
if (canSend) {
console.log('已启用消息发送功能');
}
接口函数
sendTextMessage
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SendTextMessageOptions | 发送文本弹幕参数 |
示例
import { useBarrageState } from '@/uni_modules/tuikit-atomic-x/state/BarrageState';
const { sendTextMessage } = useBarrageState('your_live_id');
sendTextMessage({ liveID: "your_live_id", text: 'Hello World' });
sendCustomMessage
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SendCustomMessageOptions | 发送自定义类型弹幕参数 |
示例
import { useBarrageState } from '@/uni_modules/tuikit-atomic-x/state/BarrageState';
const { sendCustomMessage } = useBarrageState('your_live_id');
sendCustomMessage({ liveID: "your_live_id", businessID: "livekit", data: JSON.stringify("my custom message"});
BaseBeautyState
基础美颜模块
核心功能:提供磨皮、美白、红润等基础美颜效果调节,支持实时美颜参数调整。
技术特点:基于AI美颜算法,支持实时美颜处理、参数平滑调节、性能优化等高级技术。
业务价值:为直播平台提供基础的美颜能力,提升用户形象和直播质量。
应用场景:美颜直播、形象优化、美颜调节、直播美化等需要美颜功能的场景。
响应式数据
smoothLevel
Ref
示例
import { useBeautyState } from '@/uni_modules/tuikit-atomic-x/state/BaseBeautyState';
const { smoothLevel } = useBeautyState('your_live_id');
// 监听磨皮级别变化
watch(smoothLevel, (newLevel) => {
console.log('磨皮级别:', newLevel);
});
// 获取当前磨皮级别
const level = smoothLevel.value;
console.log('当前磨皮级别:', level);
whitenessLevel
Ref
示例
import { useBeautyState } from '@/uni_modules/tuikit-atomic-x/state/BaseBeautyState';
const { whitenessLevel } = useBeautyState('your_live_id');
// 监听美白级别变化
watch(whitenessLevel, (newLevel) => {
console.log('美白级别:', newLevel);
});
// 获取当前美白级别
const level = whitenessLevel.value;
console.log('当前美白级别:', level);
ruddyLevel
Ref
示例
import { useBeautyState } from '@/uni_modules/tuikit-atomic-x/state/BaseBeautyState';
const { ruddyLevel } = useBeautyState('your_live_id');
// 监听红润级别变化
watch(ruddyLevel, (newLevel) => {
console.log('红润级别:', newLevel);
});
// 获取当前红润级别
const level = ruddyLevel.value;
console.log('当前红润级别:', level);
接口函数
setSmoothLevel
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetSmoothLevelOptions | 磨皮参数,取值范围[0,9]: 0 表示关闭,9 表示效果最明显 |
示例
import { useBeautyState } from '@/uni_modules/tuikit-atomic-x/state/BaseBeautyState';
const { setSmoothLevel } = useBeautyState('your_live_id');
setSmoothLevel({ smoothLevel: 5 });
setWhitenessLevel
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetWhitenessLevelOptions | 美白参数,取值范围[0,9]: 0 表示关闭,9 表示效果最明显 |
示例
import { useBeautyState } from '@/uni_modules/tuikit-atomic-x/state/BaseBeautyState';
const { setWhitenessLevel } = useBeautyState('your_live_id');
setWhitenessLevel({ whitenessLevel: 6 });
setRuddyLevel
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SetRuddyLevelOptions | 红润参数,取值范围[0,9]: 0 表示关闭,9 表示效果最明显 |
示例
import { useBeautyState } from '@/uni_modules/tuikit-atomic-x/state/BaseBeautyState';
const { setRuddyLevel } = useBeautyState('your_live_id');
setRuddyLevel({ ruddyLevel: 4 });
GiftState
礼物系统管理模块
核心功能:处理礼物的发送、接收、礼物列表管理等功能,支持礼物分类、礼物动画、礼物统计等完整礼物经济系统。
技术特点:支持礼物动画渲染、礼物特效处理、礼物统计、礼物排行榜等高级功能。
业务价值:为直播平台提供核心的变现能力,支持礼物经济、虚拟货币等商业模式。
应用场景:礼物打赏、虚拟货币、礼物特效、礼物统计等商业化场景。
响应式数据
usableGifts
Ref
示例
import { useGiftState } from '@/uni_modules/tuikit-atomic-x/state/GiftState';
const { usableGifts } = useGiftState('your_live_id');
// 监听可用礼物列表变化
watch(usableGifts, (newGifts) => {
if (newGifts && newGifts.length > 0) {
console.log('可用礼物更新:', newGifts);
newGifts.forEach(gift => {
console.log('礼物ID:', gift.giftID);
console.log('礼物名称:', gift.name);
console.log('礼物价格:', gift.coins);
});
}
});
// 获取当前可用礼物列表
const gifts = usableGifts.value;
console.log('当前可用礼物数量:', gifts.length);
接口函数
refreshUsableGifts
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | RefreshUsableGiftsOptions | 刷新礼物列表参数 |
示例
import { useGiftState } from '@/uni_modules/tuikit-atomic-x/state/GiftState';
const { refreshUsableGifts } = useGiftState("your_live_id");
refreshUsableGifts({});
sendGift
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SendGiftOptions | 发送礼物参数 |
示例
import { useGiftState } from '@/uni_modules/tuikit-atomic-x/state/GiftState';
const { sendGift } = useGiftState("your_live_id")
sendGift({ giftID: "gift001", count: 1 });
addGiftListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onReceiveGift'(收到礼物) |
| listener | ILiveListener | 事件监听器函数 |
示例
import { useGiftState } from '@/uni_modules/tuikit-atomic-x/state/GiftState';
const { addGiftListener } = useGiftState("your_live_id")
addGiftListener('your_live_id', 'onReceiveGift', {
callback: (params) => {
console.log('result:', params);
}
});
removeGiftListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播间ID |
| eventName | string | 事件名称,可选值: 'onReceiveGift'(收到礼物) |
| listener | ILiveListener | 事件监听器函数 |
示例
import { useGiftState } from '@/uni_modules/tuikit-atomic-x/state/GiftState';
const { removeGiftListener } = useGiftState("your_live_id")
removeGiftListener('your_live_id', 'onReceiveGift', giftListener);
LikeState
点赞互动模块
核心功能:处理直播间的点赞功能,支持点赞发送、点赞统计、点赞事件监听等互动功能。
技术特点:支持高并发点赞处理、实时点赞统计、点赞动画效果、点赞排行榜等高级功能。
业务价值:为直播平台提供基础的互动能力,增强用户参与度和直播氛围。
应用场景:点赞互动、人气统计、互动效果、用户参与等基础互动场景。
响应式数据
totalLikeCount
Ref
示例
import { useLikeState } from '@/uni_modules/tuikit-atomic-x/state/LikeState';
const { totalLikeCount } = useLikeState('your_live_id');
// 监听总点赞数量变化
watch(totalLikeCount, (newCount) => {
console.log('总点赞数量:', newCount);
if (newCount > 0) {
console.log('直播已获得点赞:', newCount);
}
});
// 获取当前总点赞数量
const likeCount = totalLikeCount.value;
console.log('当前获赞数:', likeCount);
接口函数
sendLike
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| params | SendLikeOptions | 点赞参数 |
示例
import { useLikeState } from '@/uni_modules/tuikit-atomic-x/state/LikeState';
const { sendLike } = useLikeState("your_live_id");
sendLike({ count: 1 });
addLikeListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播ID |
| eventName | string | 事件名称,可选值: 'onReceiveLikesMessage'(收到点赞消息) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useLikeState } from '@/uni_modules/tuikit-atomic-x/state/LikeState';
const { addLikeListener } = useLikeState("your_live_id");
addLikeListener('your_live_id', 'onReceiveLikesMessage', {
callback: (params) => {
console.log('result:', params);
}
});
removeLikeListener
参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| liveID | string | 直播ID |
| eventName | string | 事件名称,可选值: 'onReceiveLikesMessage'(收到点赞消息) |
| listener | ILiveListener | 事件回调函数 |
示例
import { useLikeState } from '@/uni_modules/tuikit-atomic-x/state/LikeState';
const { removeLikeListener } = useLikeState("your_live_id");
removeLikeListener('your_live_id', 'onReceiveLikesMessage', likeListener);