TUILiveKit Release Notes
Live SDK Release Notes
LiveAudienceState is a specialized module within AtomicXCore designed for managing audience information in live streaming rooms. With LiveAudienceState, you can build a robust audience list and management system for your live streaming application.
LiveAudienceState and proactively fetch the current audience list for initial display. The module automatically listens for changes in the live room state and updates the audience list when switching rooms.import { onMounted, watch } from 'vue';import { useLiveAudienceState } from "tuikit-atomicx-vue3";// Get an instance of LiveAudienceStateconst { fetchAudienceList, audienceList } = useLiveAudienceState();onMounted(async () => {try {// Fetch the audience list, returns a Promiseawait fetchAudienceList();console.log('Successfully fetched the initial audience list');} catch (error) {console.error('Failed to fetch the initial audience list', error);}});// Watch for real-time changes in audienceList to drive UI updateswatch(audienceList, (newVal) => {console.log('Audience list updated:', newVal);});
audienceState events and reactive data to receive full list snapshots and real-time audience join/leave events, enabling dynamic UI updates.import { onMounted, onUnmounted, watch } from 'vue';import { useLiveAudienceState, LiveAudienceEvent } from "tuikit-atomicx-vue3";const {audienceList,audienceCount,subscribeEvent,unsubscribeEvent} = useLiveAudienceState();// Watch for real-time changes in audienceCount to update the UI displaywatch(audienceCount, (newCount) => {console.log(`Current online audience: ${newCount}`);});// Define callback functionsconst onAudienceJoined = (eventInfo) => {console.log(`Audience member ${eventInfo.audience.userName} joined the live room`);};const onAudienceLeft = (eventInfo) => {console.log(`Audience member ${eventInfo.audience.userName} left the live room`);};onMounted(() => {// Subscribe to audience join eventsubscribeEvent(LiveAudienceEvent.onAudienceJoined, onAudienceJoined);// Subscribe to audience leave eventsubscribeEvent(LiveAudienceEvent.onAudienceLeft, onAudienceLeft);});onUnmounted(() => {// Unsubscribe when the component is unmountedunsubscribeEvent(LiveAudienceEvent.onAudienceJoined, onAudienceJoined);unsubscribeEvent(LiveAudienceEvent.onAudienceLeft, onAudienceLeft);});
kickUserOutOfRoom API to remove a specified user from the live room.import { useLiveAudienceState } from "tuikit-atomicx-vue3";const { kickUserOutOfRoom } = useLiveAudienceState();const handleKickUser = async (targetUserId: string) => {try {await kickUserOutOfRoom({ userId: targetUserId });console.log(`Host or administrator removed ${targetUserId} from the live room`);} catch (error) {console.error(`Failed to remove ${targetUserId} from the live room`, error);}};
setAdministrator and revokeAdministrator APIs to manage a user's administrator status.import { useLiveAudienceState } from "tuikit-atomicx-vue3";const { setAdministrator, revokeAdministrator } = useLiveAudienceState();const promoteToAdmin = async (targetUserId: string) => {try {await setAdministrator({ userId: targetUserId });console.log(`Successfully assigned administrator privileges to user ${targetUserId}`);} catch (error) {console.error(`Failed to assign administrator privileges to user ${targetUserId}`, error);}};const revokeAdmin = async (targetUserId: string) => {try {await revokeAdministrator({ userId: targetUserId });console.log(`Successfully revoked administrator privileges from user ${targetUserId}`);} catch (error) {console.error(`Failed to revoke administrator privileges from user ${targetUserId}`, error);}};
import { useLiveAudienceState } from "tuikit-atomicx-vue3";const { disableSendMessage } = useLiveAudienceState();// Mute userconst muteUser = async (targetUserId: string) => {await disableSendMessage({ userId: targetUserId, isDisable: true });};// Unmute userconst unmuteUser = async (targetUserId: string) => {await disableSendMessage({ userId: targetUserId, isDisable: false });};
user nickname to the live room".onAudienceJoined event and display a welcome message in the barrage/chat area.import { onMounted, onUnmounted } from 'vue';import { useLiveAudienceState, useBarrageState, LiveAudienceEvent } from "tuikit-atomicx-vue3";const { subscribeEvent, unsubscribeEvent } = useLiveAudienceState();// Assume useBarrageState provides the appendLocalTip methodconst { appendLocalTip } = useBarrageState();const handleAudienceJoin = (eventInfo) => {const { audience } = eventInfo;// Create a local tip messageconst welcomeTip = {messageType: 'text',textContent: `Welcome ${audience.userName || audience.userId} to the live room!`};// Insert local barrage messageappendLocalTip({ message: welcomeTip });console.log(`Audience member ${audience.userName} joined the live room`);};onMounted(() => {subscribeEvent(LiveAudienceEvent.onAudienceJoined, handleAudienceJoin);});onUnmounted(() => {unsubscribeEvent(LiveAudienceEvent.onAudienceJoined, handleAudienceJoin);});
State | Feature Description | API Documentation |
LiveAudienceState | Audience management: Retrieve real-time audience list (ID / name / avatar), count audience numbers, monitor audience join/leave events. | |
BarrageState | Barrage features: Send text/custom barrage messages, maintain barrage list, monitor barrage status in real time. |
audienceCount) updated in LiveAudienceState? What are the timing and frequency?audienceCount is updated with near real-time accuracy, but not always instantly. The update mechanism is as follows:audienceCount in LiveAudienceState are reflected almost instantly.audienceCount provides a highly accurate, near real-time estimate. However, in extreme high-concurrency scenarios, brief delays or data loss may occur. We recommend using audienceCount for UI display purposes only, and not as the sole source for billing, analytics, or other use cases requiring absolute precision.피드백