tencent cloud

Tencent Real-Time Communication

お知らせ・リリースノート
製品アップデート情報
Tencent Cloudオーディオビデオ端末SDKの再生アップグレードおよび承認チェック追加に関するお知らせ
TRTCアプリケーションのサブスクリプションパッケージサービスのリリースに関する説明について
製品の説明
製品概要
基礎概念
製品の機能
製品の強み
ユースケース
性能データ
購入ガイド
Billing Overview
無料時間の説明
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
課金に関するよくあるご質問
Refund Instructions
初心者ガイド
Demo体験
Call
コンポーネントの説明(TUICallKit)
Activate the Service
Run Demo
クイック導入
オフライン通知
Conversational Chat
クラウドレコーディング(TUICallKit)
AI Noise Reduction
インターフェースのカスタマイズ
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
公開ログ
よくある質問
ライブ配信
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
高度な機能
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
よくあるご質問
課金関連問題
機能関連
UserSig関連
ファイアウォールの制限の対応関連
インストールパッケージの圧縮に関するご質問
AndriodおよびiOS関連
Web端末関連
Flutter関連
Electron関連
TRTCCalling Web関連
オーディオビデオ品質関連
その他のご質問
旧バージョンのドキュメント
TUIRoom(Web)の統合
TUIRoom (Android)の統合
TUIRoom (iOS)の統合
TUIRoom (Flutter)の統合
TUIRoom (Electron)の統合
TUIRoom APIのクエリー
クラウドレコーディングと再生の実現(旧)
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.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック