AtomicX-Core SDK API Documentation
AtomicX-Core SDK
AtomicX-Core SDK is Tencent Cloud's next-generation reactive API for instant messaging, audio-video calling, live streaming, and voice chat scenarios. You can quickly build your own UI pages based on this set of APIs. It supports room management, screen sharing, member management, seat control, basic beauty effects, and more. Built on TRTC SDK, it provides ultra-low latency and high-quality audio-video experiences. This page contains all API interfaces of the AtomicX-Core SDK, organized by functional modules.
LoginState
User Authentication and Login Management Module
Core Features: Responsible for user authentication, login state management, user information maintenance and other basic authentication services.
Technical Features: Supports multiple authentication methods, session management, permission verification and other advanced features to ensure user identity security and validity.
Business Value: Provides basic user authentication capabilities for live streaming platforms, which is a prerequisite for all other business modules.
Application Scenarios: User login, identity verification, session management, permission control and other basic authentication scenarios.
Core Features: Responsible for user authentication, login state management, user information maintenance and other basic authentication services.
Technical Features: Supports multiple authentication methods, session management, permission verification and other advanced features to ensure user identity security and validity.
Business Value: Provides basic user authentication capabilities for live streaming platforms, which is a prerequisite for all other business modules.
Application Scenarios: User login, identity verification, session management, permission control and other basic authentication scenarios.
Reactive Data
loginUserInfo
const loginUserInfo: Ref
Type:
Ref
Example
```tsx
const { loginUserInfo } = useLoginState();
if (loginUserInfo) {
console.log('Current user:', loginUserInfo.nickname);
console.log('User ID:', loginUserInfo.userID);
} else {
console.log('User not logged in');
}
```
loginStatus
const loginStatus: Ref
Type:
Ref
Example
```tsx
const { loginStatus } = useLoginState();
switch (loginStatus) {
case 'LOGINED':
console.log('User logged in');
break;
case 'LOGOUT':
console.log('User logged out');
break;
case 'UNLOGIN':
console.log('User not logged in');
break;
}
```
API Functions
login
function login(params: LoginOptions)
Login method
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | LoginOptions | Login parameters |
Example
```tsx
await login({
sdkAppID: 1400000000,
userID: 'user123',
userSig: 'eJx1kF1PwzAMhv9KlG...',
onSuccess: () => console.log('Login successfully'),
onError: (error) => console.error('Login failed:', error)
});
```
logout
function logout(params?: LogoutOptions)
Logout method
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | LogoutOptions | Logout parameters (optional) |
Example
```tsx
await logout({
onSuccess: () => console.log('Logout successfully'),
onError: (error) => console.error('Logout failed:', error)
});
```
setSelfInfo
function setSelfInfo(userInfo: SetSelfInfoOptions)
Set user information
Parameters
| Parameter | Type | Description |
|---|---|---|
| userInfo | SetSelfInfoOptions | User information |
Example
```tsx
await setSelfInfo({
userProfile: {
userID: 'user123',
nickname: 'Zhang San',
avatarURL: 'https://example.com/avatar.jpg',
},
onSuccess: () => console.log('Set user info successfully'),
onError: (error) => console.error('Set user info failed:', error)
});
```
getLoginUserInfo
function getLoginUserInfo()
Get login user information
Example
```tsx
const userInfo = getLoginUserInfo();
if (userInfo) {
console.log('Current user:', userInfo.nickname);
}
```
addLoginListener
function addLoginListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add login event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listener | Function | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addLoginListener('onLoginStatusChanged', (params) => {
console.log('Login status changed:', params);
});
```
removeLoginListener
function removeLoginListener(eventName: string, listenerID?: string)
Remove login event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeLoginListener('onLoginStatusChanged');
```
LiveListState
Live Room List Management Module
Core Features: Manages the live room list display, room search, filtering and sorting functions.
Technical Features: Supports pagination loading, real-time data updates, multi-dimensional filtering and intelligent sorting.
Business Value: Provides users with a convenient live room discovery and browsing experience.
Application Scenarios: Live room list display, room search, category filtering, popularity sorting and other scenarios.
Core Features: Manages the live room list display, room search, filtering and sorting functions.
Technical Features: Supports pagination loading, real-time data updates, multi-dimensional filtering and intelligent sorting.
Business Value: Provides users with a convenient live room discovery and browsing experience.
Application Scenarios: Live room list display, room search, category filtering, popularity sorting and other scenarios.
Reactive Data
liveList
const liveList: Ref
Type:
Ref
Example
```tsx
const { liveList } = useLiveListState();
// Render list
liveList.forEach(live => {
console.log('Live room:', live.liveID);
});
```
liveListCursor
const liveListCursor: Ref
Type:
Ref
Example
```tsx
const { liveListCursor, fetchLiveList } = useLiveListState();
// Load more lives
if (liveListCursor) {
await fetchLiveList({
cursor: liveListCursor,
limit: 20
});
} else {
console.log('No more lives');
}
```
currentLive
const currentLive: Ref
Type:
Ref
Example
```tsx
const { currentLive, setCurrentLiveInfo } = useLiveListState();
// Enter live room
setCurrentLiveInfo({ liveID: '12345', ... });
// Check if in a live room
if (currentLive) {
console.log('Current live room:', currentLive.liveID);
console.log('Anchor:', currentLive.anchorInfo.nickname);
}
```
API Functions
fetchLiveList
function fetchLiveList(params: FetchLiveListOptions)
Fetch live list
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | FetchLiveListOptions | Fetch parameters |
Example
```tsx
await fetchLiveList({ cursor: '', count: 20 });
```
createLive
function createLive(params: CreateLiveOptions)
Create live room
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CreateLiveOptions | Creation parameters |
Example
```tsx
await createLive({ liveID: 'your_live_id', title: 'my live', coverUrl: 'https://example.com/cover.jpg' });
```
joinLive
function joinLive(params: JoinLiveOptions)
Join live room
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | JoinLiveOptions | Join parameters |
Example
```tsx
await joinLive({ liveID: 'host_live_id' });
```
leaveLive
function leaveLive(params?: LeaveLiveOptions)
Leave live room
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | LeaveLiveOptions | Leave parameters (optional) |
Example
```tsx
await leaveLive();
```
endLive
function endLive(params?: EndLiveOptions)
End live
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | EndLiveOptions | End parameters (optional) |
Example
```tsx
await endLive();
```
updateLiveInfo
function updateLiveInfo(params: UpdateLiveInfoOptions)
Update live information
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | UpdateLiveInfoOptions | Update parameters |
Example
```tsx
await updateLiveInfo({ liveID: 'your_live_id', title: 'new title' });
```
addLiveListListener
function addLiveListListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add live list event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onLiveEnded' (live ended) 'onKickedOutOfLive' (kicked out of live room) |
| listener | (params?: unknown) => void | Event callback function |
Example
```tsx
addLiveListListener('onLiveEnded', {
callback: (params) => {
console.log('result:', params);
}
});
```
removeLiveListListener
function removeLiveListListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Remove live list event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onLiveEnded' (live ended) 'onKickedOutOfLive' (kicked out of live room) |
| listener | (params?: unknown) => void | Event callback function |
Example
```tsx
removeLiveListListener('onLiveEnded', liveEndedListener);
```
LiveSeatState
Live Seat Management Module
Core Features: Manages seat status, seat taking/leaving operations, seat locking/unlocking and other seat-related functions.
Technical Features: Real-time seat status synchronization, permission control, event notification mechanism.
Business Value: Provides flexible seat management capabilities for multi-person interactive live streaming.
Application Scenarios: Voice chat rooms, multi-person live streaming, interactive entertainment and other scenarios.
Core Features: Manages seat status, seat taking/leaving operations, seat locking/unlocking and other seat-related functions.
Technical Features: Real-time seat status synchronization, permission control, event notification mechanism.
Business Value: Provides flexible seat management capabilities for multi-person interactive live streaming.
Application Scenarios: Voice chat rooms, multi-person live streaming, interactive entertainment and other scenarios.
Reactive Data
seatList
const seatList: Ref
Type:
Ref
Example
```tsx
const { seatList } = useLiveSeatState(liveID);
// Display all seat information
seatList.forEach(seat => {
if (seat.userId) {
console.log(`Seat ${seat.seatIndex}: ${seat.userName}`);
console.log('Microphone:', seat.isAudioMuted ? 'Closed' : 'Open');
} else {
console.log(`Seat ${seat.seatIndex}: Available`);
}
});
```
canvas
const canvas: Ref
Type:
Ref
Example
```tsx
const { canvas } = useLiveSeatState(liveID);
if (canvas) {
console.log('Canvas mode:', canvas.mode);
console.log('Background image:', canvas.backgroundUrl);
console.log('Video stream count:', canvas.videoStreamList?.length);
}
```
speakingUsers
const speakingUsers: Ref
Type:
Ref
Example
```tsx
const { speakingUsers } = useLiveSeatState(liveID);
// Check if user is speaking
if (speakingUsers?.has(userID)) {
const volume = speakingUsers.get(userID);
console.log(`User ${userID} is speaking, volume: ${volume}`);
}
// Display all speaking users
speakingUsers?.forEach((volume, userID) => {
console.log(`${userID}: ${volume}`);
});
```
API Functions
takeSeat
function takeSeat(params: TakeSeatOptions)
User takes seat
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | TakeSeatOptions | Take seat parameters |
Example
```tsx
await takeSeat({
liveID: 'your_live_id',
seatIndex: 1,
onSuccess: () => console.log('Take seat successfully'),
onError: (error) => console.error('Take seat failed:', error)
});
```
leaveSeat
function leaveSeat(params: LeaveSeatOptions)
User leaves seat
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | LeaveSeatOptions | Leave seat parameters |
Example
```tsx
await leaveSeat({
liveID: 'your_live_id',
onSuccess: () => console.log('Leave seat successfully'),
onError: (error) => console.error('Leave seat failed:', error)
});
```
muteMicrophone
function muteMicrophone(params: MuteMicrophoneOptions)
Mute microphone
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | MuteMicrophoneOptions | Mute parameters |
Example
```tsx
await muteMicrophone({
liveID: 'your_live_id',
onSuccess: () => console.log('Mute microphone successfully'),
onError: (error) => console.error('Mute microphone failed:', error)
});
```
unmuteMicrophone
function unmuteMicrophone(params: UnmuteMicrophoneOptions)
Unmute microphone
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | UnmuteMicrophoneOptions | Unmute parameters |
Example
```tsx
await unmuteMicrophone({
liveID: 'your_live_id',
onSuccess: () => console.log('Unmute microphone successfully'),
onError: (error) => console.error('Unmute microphone failed:', error)
});
```
kickUserOutOfSeat
function kickUserOutOfSeat(params: KickUserOutOfSeatOptions)
Kick user out of seat
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | KickUserOutOfSeatOptions | Kick parameters |
Example
```tsx
await kickUserOutOfSeat({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Kick user successfully'),
onError: (error) => console.error('Kick user failed:', error)
});
```
moveUserToSeat
function moveUserToSeat(params: MoveUserToSeatOptions)
Move user to specified seat
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | MoveUserToSeatOptions | Move parameters |
Example
```tsx
await moveUserToSeat({
liveID: 'your_live_id',
fromSeatIndex: 1,
toSeatIndex: 3,
onSuccess: () => console.log('Move user successfully'),
onError: (error) => console.error('Move user failed:', error)
});
```
lockSeat
function lockSeat(params: LockSeatOptions)
Lock seat
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | LockSeatOptions | Lock parameters |
Example
```tsx
await lockSeat({
liveID: 'your_live_id',
seatIndex: 2,
onSuccess: () => console.log('Lock seat successfully'),
onError: (error) => console.error('Lock seat failed:', error)
});
```
unlockSeat
function unlockSeat(params: UnlockSeatOptions)
Unlock seat
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | UnlockSeatOptions | Unlock parameters |
Example
```tsx
await unlockSeat({
liveID: 'your_live_id',
seatIndex: 2,
onSuccess: () => console.log('Unlock seat successfully'),
onError: (error) => console.error('Unlock seat failed:', error)
});
```
openRemoteCamera
function openRemoteCamera(params: OpenRemoteCameraOptions)
Open remote camera
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | OpenRemoteCameraOptions | Open camera parameters |
Example
```tsx
await openRemoteCamera({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Open remote camera successfully'),
onError: (error) => console.error('Open remote camera failed:', error)
});
```
closeRemoteCamera
function closeRemoteCamera(params: CloseRemoteCameraOptions)
Close remote camera
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CloseRemoteCameraOptions | Close camera parameters |
Example
```tsx
await closeRemoteCamera({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Close remote camera successfully'),
onError: (error) => console.error('Close remote camera failed:', error)
});
```
openRemoteMicrophone
function openRemoteMicrophone(params: OpenRemoteMicrophoneOptions)
Open remote microphone
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | OpenRemoteMicrophoneOptions | Open microphone parameters |
Example
```tsx
await openRemoteMicrophone({
liveID: 'your_live_id',
userID: 'user123',
policy: 'UNLOCK_ONLY',
onSuccess: () => console.log('Open remote microphone successfully'),
onError: (error) => console.error('Open remote microphone failed:', error)
});
```
closeRemoteMicrophone
function closeRemoteMicrophone(params: CloseRemoteMicrophoneOptions)
Close remote microphone
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CloseRemoteMicrophoneOptions | Close microphone parameters |
Example
```tsx
await closeRemoteMicrophone({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Close remote microphone successfully'),
onError: (error) => console.error('Close remote microphone failed:', error)
});
```
addLiveSeatEventListener
function addLiveSeatEventListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add seat event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onLocalCameraOpenedByAdmin' (local camera opened by admin) 'onLocalCameraClosedByAdmin' (local camera closed by admin) 'onLocalMicrophoneOpenedByAdmin' (local microphone opened by admin) 'onLocalMicrophoneClosedByAdmin' (local microphone closed by admin) |
| listener | (params?: unknown) => void | Event handler function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addLiveSeatEventListener('onLocalCameraOpenedByAdmin', (params) => {
console.log('Local camera opened by admin:', params);
});
```
removeLiveSeatEventListener
function removeLiveSeatEventListener(eventName: string, listenerID?: string)
Remove seat event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onLocalCameraOpenedByAdmin' (local camera opened by admin) 'onLocalCameraClosedByAdmin' (local camera closed by admin) 'onLocalMicrophoneOpenedByAdmin' (local microphone opened by admin) 'onLocalMicrophoneClosedByAdmin' (local microphone closed by admin) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeLiveSeatEventListener('onLocalCameraOpenedByAdmin');
```
LiveAudienceState
Live Audience Management Module
Core Features: Manages audience lists, audience operations (kick out, ban, etc.) and audience permission control.
Technical Features: Real-time audience list updates, batch operation support, flexible permission configuration.
Business Value: Provides comprehensive audience management tools for hosts and administrators.
Application Scenarios: Audience list display, audience management, permission control and other scenarios.
Core Features: Manages audience lists, audience operations (kick out, ban, etc.) and audience permission control.
Technical Features: Real-time audience list updates, batch operation support, flexible permission configuration.
Business Value: Provides comprehensive audience management tools for hosts and administrators.
Application Scenarios: Audience list display, audience management, permission control and other scenarios.
Reactive Data
audienceList
const audienceList: Ref
Type:
Ref
Example
```tsx
const { audienceList } = useLiveAudienceState(liveID);
console.log('Current audience count:', audienceList.length);
audienceList.forEach(audience => {
console.log('Audience:', audience.nickname, audience.userID);
});
```
audienceCount
const audienceCount: Ref
Type:
Ref
Example
```tsx
const { audienceCount } = useLiveAudienceState(liveID);
const displayText = audienceCount >= 100
? '99+'
: audienceCount.toString();
console.log('Audience count:', displayText);
```
API Functions
fetchAudienceList
function fetchAudienceList(params?: FetchAudienceListOptions)
Fetch live room audience list
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | FetchAudienceListOptions | Fetch audience list parameters (optional) |
Example
```tsx
await fetchAudienceList({
liveID: 'your_live_id',
onSuccess: () => console.log('Fetch audience list successfully'),
onError: (error) => console.error('Fetch audience list failed:', error)
});
```
setAdministrator
function setAdministrator(params: SetAdministratorOptions)
Set administrator
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetAdministratorOptions | Set administrator parameters |
Example
```tsx
await setAdministrator({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Set administrator successfully'),
onError: (error) => console.error('Set administrator failed:', error)
});
```
revokeAdministrator
function revokeAdministrator(params: RevokeAdministratorOptions)
Revoke administrator permission
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RevokeAdministratorOptions | Revoke administrator parameters |
Example
```tsx
await revokeAdministrator({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Revoke administrator successfully'),
onError: (error) => console.error('Revoke administrator failed:', error)
});
```
kickUserOutOfRoom
function kickUserOutOfRoom(params: KickUserOutOfRoomOptions)
Kick user out of live room
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | KickUserOutOfRoomOptions | Kick user parameters |
Example
```tsx
await kickUserOutOfRoom({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('Kick user successfully'),
onError: (error) => console.error('Kick user failed:', error)
});
```
disableSendMessage
function disableSendMessage(params: DisableSendMessageOptions)
Disable user from sending messages
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | DisableSendMessageOptions | Disable send message parameters |
Example
```tsx
await disableSendMessage({
liveID: 'your_live_id',
userID: 'user123',
isDisable: true,
onSuccess: () => console.log('Disable send message successfully'),
onError: (error) => console.error('Disable send message failed:', error)
});
```
addAudienceListener
function addAudienceListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add audience event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onAudienceJoined' (audience joined) 'onAudienceLeft' (audience left) |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addAudienceListener('onAudienceJoined', (params) => {
console.log('Audience joined:', params);
});
```
removeAudienceListener
function removeAudienceListener(eventName: string, listenerID?: string)
Remove audience event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onAudienceJoined' (audience joined) 'onAudienceLeft' (audience left) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeAudienceListener('onAudienceJoined');
```
CoGuestState
Guest Connection Management Module
Core Features: Manages audience-host connections, including applications, invitations, connections and disconnections.
Technical Features: Two-way connection mechanism, permission verification, status synchronization.
Business Value: Provides richer interactive methods for audience participation in live streaming.
Application Scenarios: Audience connections, interactive Q&A, talent shows and other scenarios.
Core Features: Manages audience-host connections, including applications, invitations, connections and disconnections.
Technical Features: Two-way connection mechanism, permission verification, status synchronization.
Business Value: Provides richer interactive methods for audience participation in live streaming.
Application Scenarios: Audience connections, interactive Q&A, talent shows and other scenarios.
Reactive Data
connected
const connected: Ref
Type:
Ref
Example
```tsx
const { connected } = useCoGuestState(liveID);
console.log('Connected guests count:', connected.length);
connected.forEach(guest => {
console.log('Guest:', guest.userName, 'Seat:', guest.seatIndex);
});
```
invitees
const invitees: Ref
Type:
Ref
Example
```tsx
const { invitees } = useCoGuestState(liveID);
console.log('Invited users count:', invitees.length);
invitees.forEach(user => {
console.log('Invited user:', user.nickname, user.userID);
});
```
applicants
const applicants: Ref
Type:
Ref
Example
```tsx
const { applicants } = useCoGuestState(liveID);
console.log('Applicants count:', applicants.length);
applicants.forEach(user => {
console.log('Applicant:', user.nickname, user.userID);
});
```
candidates
const candidates: Ref
Type:
Ref
Example
```tsx
const { candidates } = useCoGuestState(liveID);
console.log('Candidates count:', candidates.length);
candidates.forEach(user => {
console.log('Candidate:', user.nickname, user.userID);
});
```
API Functions
applyForSeat
function applyForSeat(params: ApplyForSeatOptions)
申请连麦座位
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | ApplyForSeatOptions | 申请连麦座位参数 |
Example
```tsx
await applyForSeat({
liveID: 'your_live_id',
seatIndex: 2,
timeout: 10,
extension: 'extra info',
onSuccess: () => console.log('申请成功'),
onError: (error) => console.error('申请失败:', error)
});
```
cancelApplication
function cancelApplication(params: CancelApplicationOptions)
取消申请
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CancelApplicationOptions | 取消申请参数 |
Example
```tsx
await cancelApplication({
liveID: 'your_live_id',
onSuccess: () => console.log('取消申请成功'),
onError: (error) => console.error('取消申请失败:', error)
});
```
acceptApplication
function acceptApplication(params: AcceptApplicationOptions)
接受申请
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | AcceptApplicationOptions | 接受申请参数 |
Example
```tsx
await acceptApplication({
liveID: 'your_live_id',
userID: 'user123',
seatIndex: 0,
onSuccess: () => console.log('接受申请成功'),
onError: (error) => console.error('接受申请失败:', error)
});
```
rejectApplication
function rejectApplication(params: RejectApplicationOptions)
拒绝申请
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RejectApplicationOptions | 拒绝申请参数 |
Example
```tsx
await rejectApplication({
liveID: 'your_live_id',
userID: 'user123',
onSuccess: () => console.log('拒绝申请成功'),
onError: (error) => console.error('拒绝申请失败:', error)
});
```
inviteToSeat
function inviteToSeat(params: InviteToSeatOptions)
邀请上麦
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | InviteToSeatOptions | 邀请上麦参数 |
Example
```tsx
await inviteToSeat({
liveID: 'your_live_id',
userID: 'user123',
seatIndex: 2,
timeout: 10,
extension: 'extra info',
onSuccess: () => console.log('邀请成功'),
onError: (error) => console.error('邀请失败:', error)
});
```
cancelInvitation
function cancelInvitation(params: CancelInvitationOptions)
取消邀请
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CancelInvitationOptions | 取消邀请参数 |
Example
```tsx
await cancelInvitation({
liveID: 'your_live_id',
inviteeID: 'user123',
onSuccess: () => console.log('取消邀请成功'),
onError: (error) => console.error('取消邀请失败:', error)
});
```
acceptInvitation
function acceptInvitation(params: AcceptInvitationOptions)
接受邀请
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | AcceptInvitationOptions | 接受邀请参数 |
Example
```tsx
await acceptInvitation({
liveID: 'your_live_id',
inviterID: 'user123',
onSuccess: () => console.log('接受邀请成功'),
onError: (error) => console.error('接受邀请失败:', error)
});
```
rejectInvitation
function rejectInvitation(params: RejectInvitationOptions)
拒绝邀请
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RejectInvitationOptions | 拒绝邀请参数 |
Example
```tsx
await rejectInvitation({
liveID: 'your_live_id',
inviterID: 'user123',
onSuccess: () => console.log('拒绝邀请成功'),
onError: (error) => console.error('拒绝邀请失败:', error)
});
```
disconnect
function disconnect(params?: DisconnectOptions)
断开连麦连接
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | DisconnectOptions | 断开连接参数(可选) |
Example
```tsx
await disconnect({
liveID: 'your_live_id',
onSuccess: () => console.log('断开连接成功'),
onError: (error) => console.error('断开连接失败:', error)
});
```
addCoGuestGuestListener
function addCoGuestGuestListener(eventName: string, listener: (params?: unknown) => void, liveIDParam?: string, listenerID?: string)
添加连麦嘉宾侧事件监听
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | 事件名称,可选值: 'onHostInvitationReceived'(收到主播邀请) 'onHostInvitationCancelled'(主播取消邀请) 'onGuestApplicationResponded'(嘉宾申请响应) 'onGuestApplicationNoResponse'(嘉宾申请无响应) 'onKickedOffSeat'(被踢下座位) |
| listener | (params?: unknown) => void | 事件回调函数 |
| liveID | any | 直播间ID(可选,如果传入则使用传入的,否则使用 hook 中的 liveID) |
| listenerID | string | 监听器ID(可选) |
Example
```tsx
addCoGuestGuestListener('onHostInvitationReceived', (params) => {
console.log('收到主播邀请:', params);
});
```
removeCoGuestGuestListener
function removeCoGuestGuestListener(eventName: string, liveIDParam?: string, listenerID?: string)
移除连麦嘉宾侧事件监听
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | 事件名称,可选值: 'onHostInvitationReceived'(收到主播邀请) 'onHostInvitationCancelled'(主播取消邀请) 'onGuestApplicationResponded'(嘉宾申请响应) 'onGuestApplicationNoResponse'(嘉宾申请无响应) 'onKickedOffSeat'(被踢下座位) |
| liveID | any | 直播间ID(可选,如果传入则使用传入的,否则使用 hook 中的 liveID) |
| listenerID | string | 监听器ID(可选) |
Example
```tsx
removeCoGuestGuestListener('onHostInvitationReceived');
```
addCoGuestHostListener
function addCoGuestHostListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
添加连麦主播侧事件监听
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | 事件名称,可选值: 'onGuestApplicationReceived'(收到嘉宾申请) 'onGuestApplicationCancelled'(嘉宾取消申请) 'onGuestApplicationProcessedByOtherHost'(嘉宾申请被其他主播处理) 'onHostInvitationResponded'(主播邀请得到回应) 'onHostInvitationNoResponse'(主播邀请无响应) |
| listener | (params?: unknown) => void | 事件回调函数 |
| listenerID | string | 监听器ID(可选) |
Example
```tsx
addCoGuestHostListener('onGuestApplicationReceived', (params) => {
console.log('收到嘉宾申请:', params);
});
```
removeCoGuestHostListener
function removeCoGuestHostListener(eventName: string, listenerID?: string)
移除连麦主播侧事件监听
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | 事件名称,可选值: 'onGuestApplicationReceived'(收到嘉宾申请) 'onGuestApplicationCancelled'(嘉宾取消申请) 'onGuestApplicationProcessedByOtherHost'(嘉宾申请被其他主播处理) 'onHostInvitationResponded'(主播邀请得到回应) 'onHostInvitationNoResponse'(主播邀请无响应) |
| listenerID | string | 监听器ID(可选) |
Example
```tsx
removeCoGuestHostListener('onGuestApplicationReceived');
```
CoHostState
Co-Host Connection Management Module
Core Features: Manages PK battles between hosts, including invitations, responses, connections and disconnections.
Technical Features: Real-time connection status synchronization, automatic exception handling, stable connection guarantee.
Business Value: Provides interactive entertainment features for multi-host collaboration and competition.
Application Scenarios: Host PK, co-host live streaming, interactive battles and other scenarios.
Core Features: Manages PK battles between hosts, including invitations, responses, connections and disconnections.
Technical Features: Real-time connection status synchronization, automatic exception handling, stable connection guarantee.
Business Value: Provides interactive entertainment features for multi-host collaboration and competition.
Application Scenarios: Host PK, co-host live streaming, interactive battles and other scenarios.
Reactive Data
connected
const connected: Ref
Type:
Ref
Example
```tsx
const { connected } = useCoHostState(liveID);
console.log('Connected hosts count:', connected.length);
connected.forEach(host => {
console.log('Host:', host.nickname, host.userID);
});
```
invitees
const invitees: Ref
Type:
Ref
Example
```tsx
const { invitees } = useCoHostState(liveID);
console.log('Invited hosts count:', invitees.length);
invitees.forEach(host => {
console.log('Invited host:', host.nickname, host.userID);
});
```
applicant
const applicant: Ref
Type:
Ref
Example
```tsx
const { applicant } = useCoHostState(liveID);
if (applicant) {
console.log('Applicant host:', applicant.nickname, applicant.userID);
}
```
candidates
const candidates: Ref
Type:
Ref
Example
```tsx
const { candidates } = useCoHostState(liveID);
console.log('Candidate hosts count:', candidates.length);
candidates.forEach(host => {
console.log('Candidate host:', host.nickname, host.userID);
});
```
coHostStatus
const coHostStatus: Ref
Type:
Ref
Example
```tsx
const { coHostStatus } = useCoHostState(liveID);
console.log('Current co-host status:', coHostStatus);
if (coHostStatus === CoHostStatus.CONNECTED) {
console.log('Connected');
}
```
API Functions
requestHostConnection
function requestHostConnection(params: RequestHostConnectionOptions)
Request host connection
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RequestHostConnectionOptions | Request host connection parameters |
Example
```tsx
await requestHostConnection({
liveID: 'your_live_id',
onSuccess: () => console.log('Request connection successfully'),
onError: (error) => console.error('Request connection failed:', error)
});
```
cancelHostConnection
function cancelHostConnection(params: CancelHostConnectionOptions)
Cancel host connection request
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CancelHostConnectionOptions | Cancel host connection request parameters |
Example
```tsx
await cancelHostConnection({
liveID: 'your_live_id',
toHostLiveID: 'target_live_id',
onSuccess: () => console.log('Cancel connection request successfully'),
onError: (error) => console.error('Cancel connection request failed:', error)
});
```
acceptHostConnection
function acceptHostConnection(params: AcceptHostConnectionOptions)
Accept host connection request
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | AcceptHostConnectionOptions | Accept host connection request parameters |
Example
```tsx
await acceptHostConnection({
liveID: 'your_live_id',
fromHostLiveID: 'from_live_id',
onSuccess: () => console.log('Accept connection request successfully'),
onError: (error) => console.error('Accept connection request failed:', error)
});
```
rejectHostConnection
function rejectHostConnection(params: RejectHostConnectionOptions)
Reject host connection request
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RejectHostConnectionOptions | Reject host connection request parameters |
Example
```tsx
await rejectHostConnection({
liveID: 'your_live_id',
fromHostLiveID: 'from_live_id',
onSuccess: () => console.log('Reject connection request successfully'),
onError: (error) => console.error('Reject connection request failed:', error)
});
```
exitHostConnection
function exitHostConnection(params?: ExitHostConnectionOptions)
Exit host connection
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | ExitHostConnectionOptions | Exit host connection parameters (optional) |
Example
```tsx
await exitHostConnection({
liveID: 'your_live_id',
onSuccess: () => console.log('Exit connection successfully'),
onError: (error) => console.error('Exit connection failed:', error)
});
```
addCoHostListener
function addCoHostListener(eventName: string, listener: (params?: unknown) => void, liveIDParam?: string, listenerID?: string)
Add co-host event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onCoHostRequestReceived'(received connection request) 'onCoHostRequestCancelled'(connection request cancelled) 'onCoHostRequestAccepted'(connection request accepted) 'onCoHostRequestRejected'(connection request rejected) 'onCoHostRequestTimeout'(connection request timeout) 'onCoHostUserJoined'(co-host user joined) 'onCoHostUserLeft'(co-host user left) |
| listener | (params?: unknown) => void | Event callback function |
| liveID | any | Live room ID (optional, uses the passed value if provided, otherwise uses the liveID from the hook) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addCoHostListener('onCoHostRequestReceived', (params) => {
console.log('Received connection request:', params);
});
```
removeCoHostListener
function removeCoHostListener(eventName: string, liveIDParam?: string, listenerID?: string)
Remove co-host event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onCoHostRequestReceived'(received connection request) 'onCoHostRequestCancelled'(connection request cancelled) 'onCoHostRequestAccepted'(connection request accepted) 'onCoHostRequestRejected'(connection request rejected) 'onCoHostRequestTimeout'(connection request timeout) 'onCoHostUserJoined'(co-host user joined) 'onCoHostUserLeft'(co-host user left) |
| liveID | any | Live room ID (optional, uses the passed value if provided, otherwise uses the liveID from the hook) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeCoHostListener('onCoHostRequestReceived');
```
BattleState
Battle Competition Module
Core Features: Manages competitive battles between hosts, including battle initiation, scoring and settlement.
Technical Features: Real-time scoring system, fair competition mechanism, automatic settlement process.
Business Value: Provides competitive and entertaining interactive methods for live streaming platforms.
Application Scenarios: Host battles, competitive games, interactive entertainment and other scenarios.
Core Features: Manages competitive battles between hosts, including battle initiation, scoring and settlement.
Technical Features: Real-time scoring system, fair competition mechanism, automatic settlement process.
Business Value: Provides competitive and entertaining interactive methods for live streaming platforms.
Application Scenarios: Host battles, competitive games, interactive entertainment and other scenarios.
Reactive Data
currentBattleInfo
const currentBattleInfo: Ref
Current battle information
@description Stores detailed information of current battle, including battle ID, state, duration, etc. null means no ongoing battle
@default Get initial value from global store
Type:
Ref
battleUsers
const battleUsers: Ref
Battle user list
@description List of all users participating in current battle, including user basic information and battle state
@default Get initial value from global store
Type:
Ref
battleScore
const battleScore: Ref
Battle score mapping
@description Stores scores of users in battle, key is user ID, value is score, null means no score data
@default Get initial value from global store
Type:
Ref
API Functions
requestBattle
function requestBattle(params: RequestBattleOptions)
Request battle
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RequestBattleOptions | Request battle parameters |
Example
```tsx
await requestBattle({
liveID: 'your_live_id',
userIDList: ['target_user_id'],
timeout: 10,
config: {
duration: 300,
needResponse: true,
},
onSuccess: (battleInfo) => console.log('Battle request successful:', battleInfo),
onError: (error) => console.error('Battle request failed:', error)
});
```
cancelBattleRequest
function cancelBattleRequest(params: CancelBattleRequestOptions)
Cancel battle request
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | CancelBattleRequestOptions | Cancel battle request parameters |
Example
```tsx
await cancelBattleRequest({
liveID: 'your_live_id',
battleID: 'battle_id',
userIDList: ['target_user_id'],
onSuccess: () => console.log('Battle request cancelled successfully'),
onError: (error) => console.error('Cancel battle request failed:', error)
});
```
acceptBattle
function acceptBattle(params: AcceptBattleOptions)
Accept battle
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | AcceptBattleOptions | Accept battle parameters |
Example
```tsx
await acceptBattle({
liveID: 'your_live_id',
battleID: 'battle_id',
onSuccess: () => console.log('Battle accepted successfully'),
onError: (error) => console.error('Accept battle failed:', error)
});
```
rejectBattle
function rejectBattle(params: RejectBattleOptions)
Reject battle
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RejectBattleOptions | Reject battle parameters |
Example
```tsx
await rejectBattle({
liveID: 'your_live_id',
battleID: 'battle_id',
onSuccess: () => console.log('Battle rejected successfully'),
onError: (error) => console.error('Reject battle failed:', error)
});
```
exitBattle
function exitBattle(params: ExitBattleOptions)
Exit battle
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | ExitBattleOptions | Exit battle parameters |
Example
```tsx
await exitBattle({
liveID: 'your_live_id',
battleID: 'battle_id',
onSuccess: () => console.log('Exited battle successfully'),
onError: (error) => console.error('Exit battle failed:', error)
});
```
addBattleListener
function addBattleListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add battle event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, optional values: 'onBattleStarted'(Battle started) 'onBattleEnded'(Battle ended) 'onUserJoinBattle'(User joined battle) 'onUserExitBattle'(User exited battle) 'onBattleRequestReceived'(Battle request received) 'onBattleRequestCancelled'(Battle request cancelled) 'onBattleRequestTimeout'(Battle request timeout) 'onBattleRequestAccept'(Battle request accepted) 'onBattleRequestReject'(Battle request rejected) |
| listener | (params?: unknown) => void | Event handler function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addBattleListener('onBattleStarted', (params) => {
console.log('Battle started:', params);
});
```
removeBattleListener
function removeBattleListener(eventName: string, listenerID?: string)
Remove battle event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, optional values: 'onBattleStarted'(Battle started) 'onBattleEnded'(Battle ended) 'onUserJoinBattle'(User joined battle) 'onUserExitBattle'(User exited battle) 'onBattleRequestReceived'(Battle request received) 'onBattleRequestCancelled'(Battle request cancelled) 'onBattleRequestTimeout'(Battle request timeout) 'onBattleRequestAccept'(Battle request accepted) 'onBattleRequestReject'(Battle request rejected) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeBattleListener('onBattleStarted');
```
DeviceState
Device Management Module
Core Features: Manages audio/video device status, including cameras, microphones, speakers and other device controls.
Technical Features: Device enumeration, status monitoring, automatic switching, permission management.
Business Value: Provides stable device management capabilities to ensure smooth audio/video communication.
Application Scenarios: Device switching, volume control, mirror settings and other scenarios.
Core Features: Manages audio/video device status, including cameras, microphones, speakers and other device controls.
Technical Features: Device enumeration, status monitoring, automatic switching, permission management.
Business Value: Provides stable device management capabilities to ensure smooth audio/video communication.
Application Scenarios: Device switching, volume control, mirror settings and other scenarios.
Reactive Data
microphoneStatus
const microphoneStatus: Ref
Type:
Ref
Example
```tsx
const { microphoneStatus } = useDeviceState();
console.log('Microphone status:', microphoneStatus);
if (microphoneStatus === DeviceStatus.ON) {
console.log('Microphone is on');
}
```
microphoneLastError
const microphoneLastError: Ref
Type:
Ref
Example
```tsx
const { microphoneLastError } = useDeviceState();
if (microphoneLastError === DeviceErrorEnum.NO_SYSTEM_PERMISSION) {
console.log('Microphone permission not granted');
}
```
hasPublishAudioPermission
const hasPublishAudioPermission: Ref
Type:
Ref
Example
```tsx
const { hasPublishAudioPermission } = useDeviceState();
console.log('Audio publish permission:', hasPublishAudioPermission);
```
captureVolume
const captureVolume: Ref
Type:
Ref
Example
```tsx
const { captureVolume } = useDeviceState();
console.log('Capture volume:', captureVolume);
```
currentMicVolume
const currentMicVolume: Ref
Type:
Ref
Example
```tsx
const { currentMicVolume } = useDeviceState();
console.log('Current microphone volume:', currentMicVolume);
```
cameraStatus
const cameraStatus: Ref
Type:
Ref
Example
```tsx
const { cameraStatus } = useDeviceState();
console.log('Camera status:', cameraStatus);
if (cameraStatus === DeviceStatus.ON) {
console.log('Camera is on');
}
```
cameraLastError
const cameraLastError: Ref
Type:
Ref
Example
```tsx
const { cameraLastError } = useDeviceState();
if (cameraLastError === DeviceErrorEnum.NO_DEVICE_DETECTED) {
console.log('No camera detected');
}
```
isFrontCamera
const isFrontCamera: Ref
Type:
Ref
Example
```tsx
const { isFrontCamera } = useDeviceState();
console.log('Is front camera:', isFrontCamera);
```
localMirrorType
const localMirrorType: Ref
Type:
Ref
Example
```tsx
const { localMirrorType } = useDeviceState();
console.log('Local mirror type:', localMirrorType);
```
localVideoQuality
const localVideoQuality: Ref
Type:
Ref
Example
```tsx
const { localVideoQuality } = useDeviceState();
if (localVideoQuality) {
console.log('Video quality:', localVideoQuality);
}
```
outputVolume
const outputVolume: Ref
Type:
Ref
Example
```tsx
const { outputVolume } = useDeviceState();
console.log('Output volume:', outputVolume);
```
currentAudioRoute
const currentAudioRoute: Ref
Type:
Ref
Example
```tsx
const { currentAudioRoute } = useDeviceState();
console.log('Current audio route:', currentAudioRoute);
```
screenStatus
const screenStatus: Ref
Type:
Ref
Example
```tsx
const { screenStatus } = useDeviceState();
console.log('Screen share status:', screenStatus);
```
networkInfo
const networkInfo: Ref
Type:
Ref
Example
```tsx
const { networkInfo } = useDeviceState();
if (networkInfo) {
console.log('Network info:', networkInfo);
}
```
API Functions
openLocalMicrophone
function openLocalMicrophone(params?: OpenLocalMicrophoneOptions)
Open local microphone
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | OpenLocalMicrophoneOptions | Microphone parameters (optional) |
Example
```tsx
await openLocalMicrophone({
onSuccess: () => console.log('Microphone opened'),
onError: (error) => console.error('Open microphone failed:', error)
});
```
closeLocalMicrophone
function closeLocalMicrophone()
Close local microphone
Example
```tsx
closeLocalMicrophone();
```
setCaptureVolume
function setCaptureVolume(params: VolumeOptions)
Set capture volume
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | VolumeOptions | Volume parameters |
Example
```tsx
setCaptureVolume({
volume: 80,
onSuccess: () => console.log('Volume set successfully'),
onError: (error) => console.error('Set volume failed:', error)
});
```
setOutputVolume
function setOutputVolume(params: VolumeOptions)
Set output volume
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | VolumeOptions | Volume parameters |
Example
```tsx
setOutputVolume({
volume: 90,
onSuccess: () => console.log('Output volume set successfully'),
onError: (error) => console.error('Set output volume failed:', error)
});
```
setAudioRoute
function setAudioRoute(params: SetAudioRouteOptions)
Set audio route
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetAudioRouteOptions | Audio route parameters |
Example
```tsx
setAudioRoute({
route: 'SPEAKERPHONE',
onSuccess: () => console.log('Audio route set successfully'),
onError: (error) => console.error('Set audio route failed:', error)
});
```
openLocalCamera
function openLocalCamera(params?: OpenLocalCameraOptions)
Open local camera
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | OpenLocalCameraOptions | Camera parameters (optional) |
Example
```tsx
await openLocalCamera({
isFront: true,
onSuccess: () => console.log('Camera opened'),
onError: (error) => console.error('Open camera failed:', error)
});
```
closeLocalCamera
function closeLocalCamera()
Close local camera
Example
```tsx
closeLocalCamera();
```
switchCamera
function switchCamera(params: SwitchCameraOptions)
Switch camera front/back
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SwitchCameraOptions | Switch parameters |
Example
```tsx
switchCamera({
isFront: true,
onSuccess: () => console.log('Camera switched successfully'),
onError: (error) => console.error('Switch camera failed:', error)
});
```
switchMirror
function switchMirror(params: SwitchMirrorOptions)
Switch mirror
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SwitchMirrorOptions | Mirror parameters |
Example
```tsx
switchMirror({
mirrorType: MirrorType.AUTO,
onSuccess: () => console.log('Mirror switched successfully'),
onError: (error) => console.error('Switch mirror failed:', error)
});
```
updateVideoQuality
function updateVideoQuality(params: UpdateVideoQualityOptions)
Update video quality
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | UpdateVideoQualityOptions | Video quality parameters |
Example
```tsx
updateVideoQuality({
quality: 'VIDEOQUALITY_1080P',
onSuccess: () => console.log('Video quality updated successfully'),
onError: (error) => console.error('Update video quality failed:', error)
});
```
addDeviceListener
function addDeviceListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add device event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addDeviceListener('onDeviceStatusChanged', (params) => {
console.log('Device status changed:', params);
});
```
removeDeviceListener
function removeDeviceListener(eventName: string, listenerID?: string)
Remove device event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeDeviceListener('onDeviceStatusChanged');
```
AudioEffectState
Audio Effect Management Module
Core Features: Manages audio effects, including voice changers, reverb, in-ear monitoring and other audio processing functions.
Technical Features: Real-time audio processing, multiple effect options, parameter adjustment support.
Business Value: Provides rich audio effect options to enhance live streaming entertainment.
Application Scenarios: Voice changing, reverb effects, in-ear monitoring and other scenarios.
Core Features: Manages audio effects, including voice changers, reverb, in-ear monitoring and other audio processing functions.
Technical Features: Real-time audio processing, multiple effect options, parameter adjustment support.
Business Value: Provides rich audio effect options to enhance live streaming entertainment.
Application Scenarios: Voice changing, reverb effects, in-ear monitoring and other scenarios.
Reactive Data
isEarMonitorOpened
const isEarMonitorOpened: Ref
Ear monitor switch state
@description Controls whether to enable ear monitor function, true for enabled, false for disabled
@default Get initial value from global store
Type:
Ref
earMonitorVolume
const earMonitorVolume: Ref
Ear monitor volume level
@description Volume level of ear monitor function, used to adjust ear monitor sound level
@default Get initial value from global store
Type:
Ref
audioChangerType
const audioChangerType: Ref
Voice changer type
@description Current applied voice changer effect type, supports multiple voice effects (e.g., male voice, female voice, metallic, etc.)
@default Get initial value from global store
Type:
Ref
audioReverbType
const audioReverbType: Ref
Reverb type
@description Current applied reverb effect type, supports multiple reverb effects (e.g., KTV, auditorium, deep, etc.)
@default Get initial value from global store
Type:
Ref
API Functions
setAudioChangerType
function setAudioChangerType(params: SetAudioChangerTypeOptions)
Set voice changer effect
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetAudioChangerTypeOptions | Voice changer effect parameters |
Example
```tsx
await setAudioChangerType({
changerType: 'MAN',
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
setAudioReverbType
function setAudioReverbType(params: SetAudioReverbTypeOptions)
Set reverb effect
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetAudioReverbTypeOptions | Reverb effect parameters |
Example
```tsx
await setAudioReverbType({
reverbType: 'KTV',
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
setVoiceEarMonitorEnable
function setVoiceEarMonitorEnable(params: SetVoiceEarMonitorEnableOptions)
Set ear monitor switch state
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetVoiceEarMonitorEnableOptions | Ear monitor switch parameters |
Example
```tsx
await setVoiceEarMonitorEnable({
enable: true,
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
setVoiceEarMonitorVolume
function setVoiceEarMonitorVolume(params: VolumeOptions)
Set ear monitor volume level
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | VolumeOptions | Ear monitor volume parameters |
Example
```tsx
await setVoiceEarMonitorVolume({
volume: 50,
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
addAudioEffectListener
function addAudioEffectListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add audio effect event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addAudioEffectListener('onAudioEffectChanged', (params) => {
console.log('Audio effect changed:', params);
});
```
removeAudioEffectListener
function removeAudioEffectListener(eventName: string, listenerID?: string)
Remove audio effect event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeAudioEffectListener('onAudioEffectChanged');
```
BarrageState
Barrage Management Module
Core Features: Manages barrage message sending, receiving, display and filtering functions.
Technical Features: Real-time message synchronization, barrage filtering, performance optimization.
Business Value: Provides real-time interactive communication methods for live streaming platforms.
Application Scenarios: Barrage chatting, message interaction, content filtering and other scenarios.
Core Features: Manages barrage message sending, receiving, display and filtering functions.
Technical Features: Real-time message synchronization, barrage filtering, performance optimization.
Business Value: Provides real-time interactive communication methods for live streaming platforms.
Application Scenarios: Barrage chatting, message interaction, content filtering and other scenarios.
Reactive Data
messageList
const messageList: Ref
Current room's barrage message list
@description Stores all barrage messages in the live room, including text messages, custom messages, and other barrage data types
@default Get initial value from global store
Type:
Ref
allowSendMessage
const allowSendMessage: Ref
Whether sending messages is allowed
@description Controls whether the user has permission to send barrage messages, true for allowed, false for prohibited
@default Get initial value from global store
Type:
Ref
API Functions
sendTextMessage
function sendTextMessage(params: SendTextMessageOptions)
Send text type barrage
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SendTextMessageOptions | Send text barrage parameters |
Example
```tsx
await sendTextMessage({
liveID: 'your_live_id',
text: 'Hello World',
onSuccess: () => console.log('Sent successfully'),
onError: (error) => console.error('Send failed:', error)
});
```
sendCustomMessage
function sendCustomMessage(params: SendCustomMessageOptions)
Send custom type barrage
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SendCustomMessageOptions | Send custom type barrage parameters |
Example
```tsx
await sendCustomMessage({
liveID: 'your_live_id',
businessID: 'livekit',
data: JSON.stringify('my custom message'),
onSuccess: () => console.log('Sent successfully'),
onError: (error) => console.error('Send failed:', error)
});
```
appendLocalTip
function appendLocalTip(params: AppendLocalTipOptions)
Add local tip message
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | AppendLocalTipOptions | Add local tip message parameters |
Example
```tsx
await appendLocalTip({
liveID: 'your_live_id',
message: { text: 'Hello World' },
onSuccess: () => console.log('Added successfully'),
onError: (error) => console.error('Add failed:', error)
});
```
addBarrageListener
function addBarrageListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add barrage event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addBarrageListener('onMessageReceived', (params) => {
console.log('Message received:', params);
});
```
removeBarrageListener
function removeBarrageListener(eventName: string, listenerID?: string)
Remove barrage event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeBarrageListener('onMessageReceived');
```
BaseBeautyState
Basic Beauty Management Module
Core Features: Manages basic beauty functions, including smoothing, whitening, rosy and other beauty effects.
Technical Features: Real-time beauty processing, adjustable effect levels, optimized performance design.
Business Value: Provides beauty enhancement features to improve host image quality.
Application Scenarios: Face beautification, skin smoothing, complexion adjustment and other scenarios.
Core Features: Manages basic beauty functions, including smoothing, whitening, rosy and other beauty effects.
Technical Features: Real-time beauty processing, adjustable effect levels, optimized performance design.
Business Value: Provides beauty enhancement features to improve host image quality.
Application Scenarios: Face beautification, skin smoothing, complexion adjustment and other scenarios.
Reactive Data
smoothLevel
const smoothLevel: Ref
Smoothing level
@description Value range [0,9]: 0 means off, 9 means most obvious effect
@default Get initial value from global store
Type:
Ref
whitenessLevel
const whitenessLevel: Ref
Whitening level
@description Value range [0,9]: 0 means off, 9 means most obvious effect
@default Get initial value from global store
Type:
Ref
ruddyLevel
const ruddyLevel: Ref
Ruddiness level
@description Value range [0,9]: 0 means off, 9 means most obvious effect
@default Get initial value from global store
Type:
Ref
API Functions
setSmoothLevel
function setSmoothLevel(params: SetSmoothLevelOptions)
Set smoothing level
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetSmoothLevelOptions | Smoothing parameters, value range [0,9]: 0 means off, 9 means most obvious effect |
Example
```tsx
await setSmoothLevel({
smoothLevel: 5,
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
setWhitenessLevel
function setWhitenessLevel(params: SetWhitenessLevelOptions)
Set whitening level
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetWhitenessLevelOptions | Whitening parameters, value range [0,9]: 0 means off, 9 means most obvious effect |
Example
```tsx
await setWhitenessLevel({
whitenessLevel: 6,
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
setRuddyLevel
function setRuddyLevel(params: SetRuddyLevelOptions)
Set ruddiness level
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetRuddyLevelOptions | Ruddiness parameters, value range [0,9]: 0 means off, 9 means most obvious effect |
Example
```tsx
await setRuddyLevel({
ruddyLevel: 4,
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
setRealUiValue
function setRealUiValue(type: BeautyType, value: number)
Set real UI value
Update both component local state and global store to ensure persistence
Parameters
| Parameter | Type | Description |
|---|---|---|
| type | BeautyType | Beauty type |
| value | number | Value |
Example
```tsx
setRealUiValue('smooth', 5);
```
getRealUiValue
function getRealUiValue(type: BeautyType)
Get real UI value
Parameters
| Parameter | Type | Description |
|---|---|---|
| type | BeautyType | Beauty type |
Example
```tsx
const value = getRealUiValue('smooth');
```
resetRealUiValues
function resetRealUiValues()
Reset real UI values
Reset both component local state and global store
Example
```tsx
resetRealUiValues();
```
addBeautyListener
function addBeautyListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add beauty event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addBeautyListener('onBeautyLevelChanged', (params) => {
console.log('Beauty level changed:', params);
});
```
removeBeautyListener
function removeBeautyListener(eventName: string, listenerID?: string)
Remove beauty event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeBeautyListener('onBeautyLevelChanged');
```
GiftState
Gift Management Module
Core Features: Manages gift display, sending, receiving and effect playback functions.
Technical Features: Real-time gift synchronization, effect animation, gift statistics.
Business Value: Provides monetization channels and interactive entertainment methods for live streaming platforms.
Application Scenarios: Gift giving, effect display, revenue statistics and other scenarios.
Core Features: Manages gift display, sending, receiving and effect playback functions.
Technical Features: Real-time gift synchronization, effect animation, gift statistics.
Business Value: Provides monetization channels and interactive entertainment methods for live streaming platforms.
Application Scenarios: Gift giving, effect display, revenue statistics and other scenarios.
Reactive Data
usableGifts
const usableGifts: Ref
Type:
Ref
Example
```tsx
const { usableGifts } = useGiftState(liveID);
console.log('Usable gift categories count:', usableGifts.length);
usableGifts.forEach(category => {
console.log('Category:', category.name);
category.giftList?.forEach(gift => {
console.log('Gift:', gift.name, 'Price:', gift.price);
});
});
```
API Functions
refreshUsableGifts
function refreshUsableGifts(params?: RefreshUsableGiftsOptions)
Refresh usable gifts list
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | RefreshUsableGiftsOptions | Refresh gifts list parameters (optional) |
Example
```tsx
await refreshUsableGifts({
liveID: 'your_live_id',
onSuccess: () => console.log('Refresh successfully'),
onError: (error) => console.error('Refresh failed:', error)
});
```
sendGift
function sendGift(params: SendGiftOptions)
Send gift
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SendGiftOptions | Send gift parameters |
Example
```tsx
await sendGift({
liveID: 'your_live_id',
giftID: 'gift001',
count: 1,
receiverList: ['user1', 'user2'],
onSuccess: () => console.log('Send successfully'),
onError: (error) => console.error('Send failed:', error)
});
```
setLanguage
function setLanguage(params: SetLanguageOptions)
Set gift language
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SetLanguageOptions | Set gift language parameters |
Example
```tsx
await setLanguage({
liveID: 'your_live_id',
language: 'zh-CN',
onSuccess: () => console.log('Set successfully'),
onError: (error) => console.error('Set failed:', error)
});
```
addGiftListener
function addGiftListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add gift event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onReceiveGift'(received gift) |
| listener | (params?: unknown) => void | Event listener function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addGiftListener('onReceiveGift', (params) => {
console.log('Received gift:', params);
});
```
removeGiftListener
function removeGiftListener(eventName: string, listenerID?: string)
Remove gift event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onReceiveGift'(received gift) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeGiftListener('onReceiveGift');
```
LikeState
Like Management Module
Core Features: Manages like operations, including sending likes, receiving likes and like effect displays.
Technical Features: Real-time like synchronization, effect animation, performance optimization.
Business Value: Provides simple and direct interactive feedback methods for audiences.
Application Scenarios: Like interaction, effect display, popularity statistics and other scenarios.
Core Features: Manages like operations, including sending likes, receiving likes and like effect displays.
Technical Features: Real-time like synchronization, effect animation, performance optimization.
Business Value: Provides simple and direct interactive feedback methods for audiences.
Application Scenarios: Like interaction, effect display, popularity statistics and other scenarios.
Reactive Data
totalLikeCount
const totalLikeCount: Ref
Type:
Ref
Example
```tsx
const { totalLikeCount } = useLikeState(liveID);
console.log('Total like count:', totalLikeCount);
```
API Functions
sendLike
function sendLike(params: SendLikeOptions)
Send like
Parameters
| Parameter | Type | Description |
|---|---|---|
| params | SendLikeOptions | Like parameters |
Example
```tsx
await sendLike({
liveID: 'your_live_id',
count: 1,
onSuccess: () => console.log('Like sent successfully'),
onError: (error) => console.error('Send like failed:', error)
});
```
addLikeListener
function addLikeListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add like event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onReceiveLikesMessage'(received like message) |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addLikeListener('onReceiveLikesMessage', (params) => {
console.log('Received like message:', params);
});
```
removeLikeListener
function removeLikeListener(eventName: string, listenerID?: string)
Remove like event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name, options: 'onReceiveLikesMessage'(received like message) |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeLikeListener('onReceiveLikesMessage');
```
LiveSummaryState
Live Summary Module
Core Features: Manages live room data statistics and summary information.
Technical Features: Real-time data statistics, multi-dimensional data analysis, summary report generation.
Business Value: Provides data support for hosts and platforms to optimize live streaming strategies.
Application Scenarios: Data statistics, effect analysis, summary reports and other scenarios.
Core Features: Manages live room data statistics and summary information.
Technical Features: Real-time data statistics, multi-dimensional data analysis, summary report generation.
Business Value: Provides data support for hosts and platforms to optimize live streaming strategies.
Application Scenarios: Data statistics, effect analysis, summary reports and other scenarios.
Reactive Data
summaryData
const summaryData: Ref
LiveSummaryState Hook
Type:
Ref
Example
```tsx
import { useLiveSummaryState } from '@/src/atomic-x/state/LiveSummaryState';
function SummaryComponent() {
const { summaryData } = useLiveSummaryState('your_live_id');
return (
<View>
{summaryData && (
<>
<Text>Viewer count: {summaryData.viewerCount}</Text>
<Text>Like count: {summaryData.likeCount}</Text>
<Text>Gift count: {summaryData.giftCount}</Text>
</>
)}
</View>
);
}
```
API Functions
addLiveSummaryListener
function addLiveSummaryListener(eventName: string, listener: (params?: unknown) => void, listenerID?: string)
Add statistics event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listener | (params?: unknown) => void | Event callback function |
| listenerID | string | Listener ID (optional) |
Example
```tsx
addLiveSummaryListener('onSummaryDataChanged', (params) => {
console.log('Statistics data changed:', params);
});
```
removeLiveSummaryListener
function removeLiveSummaryListener(eventName: string, listenerID?: string)
Remove statistics event listener
Parameters
| Parameter | Type | Description |
|---|---|---|
| eventName | string | Event name |
| listenerID | string | Listener ID (optional) |
Example
```tsx
removeLiveSummaryListener('onSummaryDataChanged');
```