tencent cloud

Tencent Real-Time Communication

소식 및 공지 사항
제품 업데이트
Tencent Cloud 오디오/비디오 단말 SDK 재생 업그레이드 및 권한 부여 인증 추가
TRTC 월간 구독 패키지 출시 관련 안내
제품 소개
제품 개요
기본 개념
제품 기능
제품 장점
응용 시나리오
성능 데이터
구매 가이드
Billing Overview
무료 시간 안내
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
과금 FAQ
Refund Instructions
신규 사용자 가이드
Demo 체험
Call
개요(TUICallKit)
Activate the Service
Run Demo
빠른 통합(TUICallKit)
오프라인 푸시
Conversational Chat
온클라우드 녹화(TUICallKit)
AI Noise Reduction
UI 사용자 정의
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
릴리스 노트
FAQs
라이브 스트리밍
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo 실행
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDK 다운로드
API 코드 예시
Usage Guidelines
API 클라이언트 API
고급 기능
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
콘솔 가이드
애플리케이션 관리
사용량 통계
모니터링 대시보드
개발 보조
Solution
Real-Time Chorus
FAQs
과금 개요
기능 관련
UserSig 관련
방화벽 제한 처리
설치 패키지 용량 축소 관련 질문
Andriod 및 iOS 관련
Web 관련
Flutter 관련
Electron 관련
TRTCCalling Web 관련
멀티미디어 품질 관련
기타 질문
Protocols and Policies
컴플라이언스 인증
보안 백서
정보 보안에 관한 참고 사항
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약
용어집

Audience List (Flutter)

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-02-27 20:58:06
LiveAudienceStore is a module in AtomicXCore specialized in managing live streaming room audience information. With LiveAudienceStore, you can build a complete audience list and management system for your live stream application.


Core Features

Real-Time Audience List: Access and display details for all current audience members in the live room.
Audience Count Statistics: Get the real-time total number of audience members in the live room.
Audience Events: Subscribe to events to instantly detect when audience members join or leave.
Admin Privileges: Hosts can promote audience members to administrators or revoke their admin status.
Room Management: Hosts or administrators can remove (kick out) any regular audience member from the live room.

Core Concepts

The following table introduces the core concepts of LiveAudienceStore:
Core Concepts
Type
Core Responsibilities and Description
class
Represents the basic information model for an audience member. Includes the user’s unique identifier (userID), nickname (userName), and avatar URL (avatarURL).
class
Represents the current status of the audience module. Its core attribute audienceList is a ValueListenable<List<LiveUserInfo>>, storing a snapshot of the audience list; audienceCount signifies the total number of current audience.
class
Handles real-time event listening for audience activity. Includes two callbacks: onAudienceJoined (audience member joins) and onAudienceLeft (audience member leaves), used for incremental updates to the audience list.
class
The main management class for audience list operations. Use it to get audience snapshots, perform management actions, and receive real-time updates via addLiveAudienceListener.

Implementation Steps

Step 1: Integrate the Components

Live streaming: Refer to Quick Access for seamless integration with AtomicXCore and service access.
Voice chat room: Refer to Quick Access for integration with AtomicXCore and access completed.

Step 2: Initialize and Obtain Audience List

Retrieve a LiveAudienceStore instance bound to the current live streaming room liveId, actively pull the current audience list once for first-time show.
To release resources when leaving the live room, call the dispose method on AudienceManager.
import 'package:atomic_x_core/atomicxcore.dart';

class AudienceManager {
final String liveId;
late final LiveAudienceStore audienceStore;
late LiveAudienceListener _audienceListener;
late final VoidCallback _audienceListChangedListener = _onAudienceListChanged;
late final VoidCallback _audienceCountChangedListener = _onAudienceCountChanged;

// Externally exposed [full] audience list
List<LiveUserInfo> audienceList = [];
// Externally exposed total audience count
int audienceCount = 0;

// Status change callback
Function()? onStateChanged;

AudienceManager({required this.liveId}) {
// 1. Retrieve an instance of LiveAudienceStore by liveId
audienceStore = LiveAudienceStore.create(liveId);

// 2. Subscribe to status and events
_subscribeToAudienceState();
_subscribeToAudienceEvents();

// 3. Actively pull first screen data
fetchInitialAudienceList();
}

/// Proactively retrieve an audience list snapshot once
Future<void> fetchInitialAudienceList() async {
final result = await audienceStore.fetchAudienceList();
if (result.isSuccess) {
print("First pull audience list successfully");
// Upon success, data will be auto-updated via the state subscription channel below
} else {
print("First pull audience list failed: ${result.errorMessage}");
}
}

void dispose() {
audienceStore.liveAudienceState.audienceList.removeListener(_audienceListChangedListener);
audienceStore.liveAudienceState.audienceCount.removeListener(_audienceCountChangedListener);
audienceStore.removeLiveAudienceListener(_audienceListener);
}
}
The audience list and other state subscriptions will be explained in detail in the next step.

Step 3: Monitoring the Audience List Status and Real-Time Updates

Subscribe to liveAudienceState and LiveAudienceListener on audienceStore to receive full audience list snapshots and real-time join/leave events, driving UI updates.
extension AudienceManagerSubscription on AudienceManager {
/// Subscribe to state to obtain the total count of audience and list snapshots
void _subscribeToAudienceState() {
// Listen to audience list adjustments
audienceStore.liveAudienceState.audienceList.addListener(_audienceListChangedListener);
// Listen to audience change rate
audienceStore.liveAudienceState.audienceCount.addListener(_audienceCountChangedListener);
}

void _onAudienceListChanged() {
// audienceList is a full snapshot
audienceList = audienceStore.liveAudienceState.audienceList.value;
onStateChanged?.call();
}

void _onAudienceCountChanged() {
// audienceCount is the real-time total count
audienceCount = audienceStore.liveAudienceState.audienceCount.value;
onStateChanged?.call();
}

/// Subscribe to events for processing real-time audience entry and exit
void _subscribeToAudienceEvents() {
_audienceListener = LiveAudienceListener(
onAudienceJoined: (audience) {
print("Audience ${audience.userName} joined the live streaming room");
// Incremental update: Add new audience at the end of the current list
if (!audienceList.any((a) => a.userID == audience.userID)) {
audienceList.add(audience);
onStateChanged?.call();
}
},
onAudienceLeft: (audience) {
print("Audience ${audience.userName} left the live streaming room");
// Incremental update: Remove leaving audience from the current list
audienceList.removeWhere((a) => a.userID == audience.userID);
onStateChanged?.call();
},
);
audienceStore.addLiveAudienceListener(_audienceListener);
}
}

Step 4: Manage Audience Members

As a host or administrator, you can manage audience members in the live room.

4.1 Remove Audience Member from Live Room

Call the kickUserOutOfRoom API to remove designated users from the live streaming room.
extension AudienceManagerActions on AudienceManager {
Future<void> kick(String userId) async {
final result = await audienceStore.kickUserOutOfRoom(userId);
if (result.isSuccess) {
print("Successfully kicked user $userId out of room");
// Upon success, you will receive the onAudienceLeft event
} else {
print("Failed to kick out user $userId: ${result.errorMessage}");
}
}
}

4.2 Set or Revoke Administrator Privileges

Use the setAdministrator and revokeAdministrator APIs to manage user administrator privileges.
extension AudienceManagerAdmin on AudienceManager {
/// Set the user as administrator
Future<void> promoteToAdmin(String userId) async {
final result = await audienceStore.setAdministrator(userId);
if (result.isSuccess) {
print("Successfully set user $userId as administrator");
}
}

/// Revoke the user's administrator privileges
Future<void> revokeAdmin(String userId) async {
final result = await audienceStore.revokeAdministrator(userId);
if (result.isSuccess) {
print("Successfully revoked user $userId's administrator privileges");
}
}
}

Advanced Features

Show Welcome Message in Live Comments

When a new audience enters the live room, the bullet screen/chat area will automatically display a welcome message locally, such as "Welcome [user nickname] to the live room."

Implementation

Subscribe to the onAudienceJoined event from LiveAudienceStore to receive real-time notifications when a new audience member joins. When triggered, extract the user’s nickname and call the appendLocalTip API from BarrageStore to insert the welcome message.
Release resources when leaving the live room by calling the dispose method on LiveRoomManager.
import 'package:atomic_x_core/atomicxcore.dart';

class LiveRoomManager {
final String liveId;
late LiveAudienceListener _welcomeListener;

LiveRoomManager({required this.liveId}) {
_setupWelcomeMessageFlow();
}

void _setupWelcomeMessageFlow() {
// 1. Retrieve an instance of LiveAudienceStore
final audienceStore = LiveAudienceStore.create(liveId);

// 2. Retrieve an instance of BarrageStore (thanks to the internal mechanism, this will be the same instance)
final barrageStore = BarrageStore.create(liveId);

// 3. Subscribe to audience events
_welcomeListener = LiveAudienceListener(
onAudienceJoined: (audience) {
// 4. Create a local Prompt message
final welcomeTip = Barrage(
messageType: BarrageType.text,
textContent: "Welcome ${audience.userName} to the live streaming room."
);

// 5. Call the BarrageStore API to insert it into the bullet screen list
barrageStore.appendLocalTip(welcomeTip);
},
);
audienceStore.addLiveAudienceListener(_welcomeListener);
}

void dispose() {
final audienceStore = LiveAudienceStore.create(liveId);
audienceStore.removeLiveAudienceListener(_welcomeListener);
}
}

API documentation

For detailed information on all public APIs, properties, and methods for LiveAudienceStore and related classes, see the official AtomicXCore API documentation. The relevant Stores used in this guide are listed below:
Store/Component
Feature Description
API Reference
LiveCoreWidget
Core view component for live video stream display and interaction. Handles video stream rendering and widget management, supporting host live streaming, audience co-hosting, and host connection scenarios.
LiveCoreController
LiveCoreWidget controller: used to set up live streaming ID, control preview, and perform other operations.
LiveAudienceStore
Audience management: get real-time audience list (ID/name/avatar), check audience size, listen to Enter/Exit Event.
BarrageStore
Live comments: send text/custom comments, maintain the comment list, and monitor comment status in real time.

FAQs

How is the online audience count (audienceCount) in LiveAudienceState updated? What are the timing and frequency?

Active Room Entry/Exit: When a user joins or leaves the live room normally, the audience count notification is triggered instantly. You will immediately see the change in audienceCount in LiveAudienceState.
Abnormal Disconnection: If a user disconnects due to network issues, app crashes, or similar problems, the system uses a heartbeat mechanism to determine their status. Only after missing heartbeats for 90 consecutive seconds will the system consider the user offline and trigger a count change notification.
Update Mechanism & Frequency Control:
Whether triggered instantly or delayed, all audience count change notifications are sent as messages within the room.
Each room is limited to a maximum of 40 messages per second.
Key Point: In high-traffic scenarios, such as live comment storms or gift spamming, if the room’s message rate exceeds 40 messages per second, the system prioritizes core messages (like live comments). Audience count change messages may be dropped due to frequency control.
What does this mean for developers?
audienceCount is a high-precision estimate very close to real time, but under extreme high concurrency scenarios, it may have brief delay or data loss. Therefore, we recommend that you use it for UI display and should not take it as the only basis for scenarios requiring absolute accuracy such as billing or statistics.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백