@tencent-rtc/mcp 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/resource/doc/chatuikit/android/integration.md +499 -203
- package/resource/doc/chatuikit/android/workflow.md +713 -0
- package/resource/doc/chatuikit/flutter/integration.md +1 -1
- package/resource/doc/livekit/voice/android/voice-audience-list.md +334 -0
- package/resource/doc/livekit/voice/android/voice-audio-effect.md +380 -0
- package/resource/doc/livekit/voice/android/voice-barrage.md +565 -0
- package/resource/doc/livekit/voice/android/voice-co-guest-interaction.md +745 -0
- package/resource/doc/livekit/voice/android/voice-gift.md +822 -0
- package/resource/doc/livekit/voice/android/voice-host-interaction.md +703 -0
- package/resource/doc/livekit/voice/android/voice-integration.md +940 -0
- package/resource/doc/livekit/voice/android/voice-room-list.md +575 -0
- package/resource/doc/livekit/voice/flutter/voice-co-guest-interaction.md +675 -0
- package/resource/doc/livekit/voice/flutter/voice-integration.md +936 -0
- package/resource/doc/livekit/voice/ios/voice-audience-list.md +339 -0
- package/resource/doc/livekit/voice/ios/voice-audio-effect.md +370 -0
- package/resource/doc/livekit/voice/ios/voice-barrage.md +517 -0
- package/resource/doc/livekit/voice/ios/voice-co-guest-interaction.md +708 -0
- package/resource/doc/livekit/voice/ios/voice-gift.md +783 -0
- package/resource/doc/livekit/voice/ios/voice-host-interaction.md +770 -0
- package/resource/doc/livekit/voice/ios/voice-integration.md +898 -0
- package/resource/doc/livekit/voice/ios/voice-room-list.md +485 -0
- package/resource/doc/roomkit/vue/integration.md +179 -288
- package/resource/doc/roomkit/vue/workflow.md +499 -253
- package/resource/doc/tuicallkit/android/integration.md +539 -83
- package/resource/doc/tuicallkit/android/workflow.md +441 -0
- package/tools/common/present-scenario-choice.js +16 -0
- package/tools/common/present-scenario-choice.js.map +1 -0
- package/tools/definitions/get_native_call_uikit_integration_def.js +25 -9
- package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_chat_uikit_integration_def.js +36 -14
- package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_live_uikit_integration_def.js +55 -29
- package/tools/definitions/get_native_live_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_live_uikit_interaction_def.js +43 -54
- package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -1
- package/tools/definitions/get_web_room_feature_detail_def.js +52 -55
- package/tools/definitions/get_web_room_feature_detail_def.js.map +1 -1
- package/tools/definitions/get_web_room_uikit_integration_def.js +41 -25
- package/tools/definitions/get_web_room_uikit_integration_def.js.map +1 -1
- package/tools/definitions/present_scenario_choice_def.js +53 -0
- package/tools/definitions/present_scenario_choice_def.js.map +1 -0
- package/tools/definitions/record_prompt_def.js +26 -21
- package/tools/definitions/record_prompt_def.js.map +1 -1
- package/tools/definitions/record_result_def.js +20 -4
- package/tools/definitions/record_result_def.js.map +1 -1
- package/tools/index.js +2 -0
- package/tools/index.js.map +1 -1
- package/tools/live/get-native-live-uikit-integration.js +110 -34
- package/tools/live/get-native-live-uikit-integration.js.map +1 -1
- package/tools/live/get_native_live_uikit_interaction.js +128 -35
- package/tools/live/get_native_live_uikit_interaction.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
**AtomicXCore** provides [CoGuestStore](https://tencent-rtc.github.io/TUIKit_Flutter/api_live_co_guest_store/CoGuestStore-class.html) and [LiveSeatStore](https://tencent-rtc.github.io/TUIKit_Flutter/api_live_live_seat_store/LiveSeatStore-class.html) modules, used to manage the complete business process of audience mic connection. Users do not need to worry about complex state synchronization and signaling interaction, just call a few simple methods to add powerful audio-video interaction between audience and anchor to your live stream. This document will guide you on how to use `CoGuestStore` and `LiveSeatStore` for quick implementation of audio mic connection in Flutter application.
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Core Scenario
|
|
7
|
+
|
|
8
|
+
`CoGuestStore` and `LiveSeatStore` support the following mainstream scenarios:
|
|
9
|
+
- **Audience request to speak**: The audience proactively initiates a mic connection request, and the anchor can grant or reject it upon receiving the request.
|
|
10
|
+
|
|
11
|
+
- **Anchor invitation to speak**: The anchor can proactively initiate a mic connection invitation to any audience in the live streaming room.
|
|
12
|
+
|
|
13
|
+
- **Anchor seat management**: The anchor can perform operations such as forced microphone removal, muting, and locking on the user on the seat.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Implementation Steps
|
|
17
|
+
|
|
18
|
+
### Step 1: Component Integration
|
|
19
|
+
|
|
20
|
+
Refer to [quick integration](https://write.woa.com/document/200555778169073664) to integrate **AtomicXCore**.
|
|
21
|
+
|
|
22
|
+
> **Note:**
|
|
23
|
+
>
|
|
24
|
+
|
|
25
|
+
> Before implementing the co-anchoring function, you need to get the `liveId` (the unique identifier of the live streaming room) to distinguish different live streaming rooms. The method for obtaining it is as follows.
|
|
26
|
+
>
|
|
27
|
+
> - **Anchor**: Specify when creating a live stream via `LiveListStore.shared.createLive(liveInfo)`.
|
|
28
|
+
> - **Client**: Get it from `liveInfo` in `LiveListState.liveList.value`, or obtain it by the Anchor sharing the live streaming room ID.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Step 2: Implement Audience Mic-Link Request
|
|
32
|
+
|
|
33
|
+
#### Audience Side Implementation
|
|
34
|
+
|
|
35
|
+
As an audience member, your main tasks are **initiating a request, handling the response**, and **leaving the mic proactively**.
|
|
36
|
+
1. **Initiate Mic-Link Request**
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
When the user taps the "Request Mic-Link" button in the UI, call the `applyForSeat` method.
|
|
40
|
+
|
|
41
|
+
``` java
|
|
42
|
+
import 'package:atomic_x_core/atomicxcore.dart';
|
|
43
|
+
|
|
44
|
+
final String liveId = "room ID";
|
|
45
|
+
late CoGuestStore guestStore;
|
|
46
|
+
|
|
47
|
+
@override
|
|
48
|
+
void initState() {
|
|
49
|
+
super.initState();
|
|
50
|
+
guestStore = CoGuestStore.create(liveId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// User click "Apply for Mic Connection"
|
|
54
|
+
Future<void> requestToConnect() async {
|
|
55
|
+
// seatIndex: The seat index, starting from 0, represents the applied microphone position. 0 means the first seat. View seat status via LiveSeatState.seatList.value and select an idle seat.
|
|
56
|
+
// timeout: Request timeout (seconds). The audience can call cancelApplication to cancel the request to speak within the timeout period.
|
|
57
|
+
// The request will expire if it hasn't been processed after reaching the timeout period
|
|
58
|
+
final result = await guestStore.applyForSeat(
|
|
59
|
+
seatIndex: 0,
|
|
60
|
+
timeout: 30,
|
|
61
|
+
extraInfo: null,
|
|
62
|
+
);
|
|
63
|
+
if (result.isSuccess) {
|
|
64
|
+
debugPrint('Mic connection request sent, waiting for anchor processing...');
|
|
65
|
+
} else {
|
|
66
|
+
debugPrint('Failed to send request: ${result.message}');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
2. **Listen for Host Response**
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
By adding `GuestListener`, you can receive the host's response
|
|
74
|
+
|
|
75
|
+
``` java
|
|
76
|
+
late GuestListener _guestListener;
|
|
77
|
+
|
|
78
|
+
// Subscribe to events when your Widget initializes
|
|
79
|
+
void subscribeGuestEvents() {
|
|
80
|
+
_guestListener = GuestListener(
|
|
81
|
+
onGuestApplicationResponded: (isAccept, hostUser) {
|
|
82
|
+
if (isAccept) {
|
|
83
|
+
debugPrint('Anchor ${hostUser.userName} granted your request, preparing to join the mic');
|
|
84
|
+
// 1. Turn on microphone
|
|
85
|
+
// DeviceStore is the device management module provided by AtomicXCore, used for managing microphones, cameras and other physical devices.
|
|
86
|
+
// When the host agrees to connect mic, turn on microphone to start collecting audio.
|
|
87
|
+
DeviceStore.shared.openLocalMicrophone();
|
|
88
|
+
// 2. Update UI herein, such as disabling the apply button and displaying the mic connection state
|
|
89
|
+
} else {
|
|
90
|
+
debugPrint('Anchor ${hostUser.userName} refused your request');
|
|
91
|
+
// Pop-up prompts user that the application was rejected
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
guestStore.addGuestListener(_guestListener);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@override
|
|
99
|
+
void dispose() {
|
|
100
|
+
guestStore.removeGuestListener(_guestListener);
|
|
101
|
+
super.dispose();
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
3. **Leave Mic Proactively**
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
When an audience member on mic wants to end the interaction, call `disConnect` to return to regular audience status.
|
|
108
|
+
|
|
109
|
+
``` java
|
|
110
|
+
// User click "Disconnect" button
|
|
111
|
+
Future<void> leaveSeat() async {
|
|
112
|
+
final result = await guestStore.disconnect();
|
|
113
|
+
if (result.isSuccess) {
|
|
114
|
+
debugPrint('Disconnected successfully');
|
|
115
|
+
} else {
|
|
116
|
+
debugPrint('Failed to leave the seat: ${result.message}');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
4. **(Optional) Cancel Request**
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
If the audience member wants to withdraw the request before the host responds, call `cancelApplication`.
|
|
124
|
+
|
|
125
|
+
``` java
|
|
126
|
+
// While waiting, the user clicks "Cancel Application"
|
|
127
|
+
Future<void> cancelApplication() async {
|
|
128
|
+
final result = await guestStore.cancelApplication();
|
|
129
|
+
if (result.isSuccess) {
|
|
130
|
+
debugPrint('Request canceled');
|
|
131
|
+
} else {
|
|
132
|
+
debugPrint('Failed to cancel request: ${result.message}');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Host Side Implementation
|
|
138
|
+
|
|
139
|
+
As the host, your main tasks are **receiving requests, displaying the request list**, and **handling requests**.
|
|
140
|
+
1. **Listen for New Mic-Link Requests**
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
By adding `HostListener`, you can receive immediate notification when a new audience applies and prompt.
|
|
144
|
+
|
|
145
|
+
``` java
|
|
146
|
+
import 'package:atomic_x_core/atomicxcore.dart';
|
|
147
|
+
|
|
148
|
+
final String liveId = "room ID";
|
|
149
|
+
late CoGuestStore guestStore;
|
|
150
|
+
late HostListener _hostListener;
|
|
151
|
+
|
|
152
|
+
@override
|
|
153
|
+
void initState() {
|
|
154
|
+
super.initState();
|
|
155
|
+
guestStore = CoGuestStore.create(liveId);
|
|
156
|
+
|
|
157
|
+
// Subscribe to anchor event
|
|
158
|
+
_hostListener = HostListener(
|
|
159
|
+
onGuestApplicationReceived: (guestUser) {
|
|
160
|
+
debugPrint('Received mic connection request from audience ${guestUser.userName}');
|
|
161
|
+
// Update the UI here, for example display a red dot on the "application list" button
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
guestStore.addHostListener(_hostListener);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@override
|
|
168
|
+
void dispose() {
|
|
169
|
+
guestStore.removeHostListener(_hostListener);
|
|
170
|
+
super.dispose();
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
2. **Display Request List**
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
`CoGuestStore`'s `coGuestState` maintains the current applicant list in real time. You can subscribe to it to update your UI.
|
|
177
|
+
|
|
178
|
+
``` java
|
|
179
|
+
late final VoidCallback _applicantsListener = _onApplicantsChanged;
|
|
180
|
+
|
|
181
|
+
// Subscribe to status change
|
|
182
|
+
void subscribeApplicants() {
|
|
183
|
+
guestStore.coGuestState.applicants.addListener(_applicantsListener);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void _onApplicantsChanged() {
|
|
187
|
+
final applicants = guestStore.coGuestState.applicants.value;
|
|
188
|
+
debugPrint('Current number of applicants: ${applicants.length}');
|
|
189
|
+
// Update your "applicant list" UI here
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@override
|
|
193
|
+
void dispose() {
|
|
194
|
+
guestStore.coGuestState.applicants.removeListener(_applicantsListener);
|
|
195
|
+
super.dispose();
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
3. **Handle Mic-Link Requests**
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
When you select an audience member from the list and tap "Accept" or "Reject", call the corresponding method.
|
|
202
|
+
|
|
203
|
+
``` java
|
|
204
|
+
// Anchor clicks the "Grant" button and imports the applicant's userID
|
|
205
|
+
Future<void> accept(String userId) async {
|
|
206
|
+
final result = await guestStore.acceptApplication(userId);
|
|
207
|
+
if (result.isSuccess) {
|
|
208
|
+
debugPrint('Approved $userId\'s request, the other party is joining the mic');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Anchor clicks the "Reject" button
|
|
213
|
+
Future<void> reject(String userId) async {
|
|
214
|
+
final result = await guestStore.rejectApplication(userId);
|
|
215
|
+
if (result.isSuccess) {
|
|
216
|
+
debugPrint('$userId\'s application denied');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Step 3: Implement Host-Initiated Mic-Link Invitation
|
|
222
|
+
|
|
223
|
+
#### Host Side Implementation
|
|
224
|
+
1. **Invite Audience to Mic**
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
When the host selects a viewer from the audience list and taps "Invite to Mic", call the `inviteToSeat` method.
|
|
228
|
+
|
|
229
|
+
``` java
|
|
230
|
+
// Anchor selects audience and initiates invitation
|
|
231
|
+
Future<void> invite(String userId) async {
|
|
232
|
+
// inviteeID: The ID of the invitee, seatIndex: The seat index, timeout: The invitation timeout duration
|
|
233
|
+
final result = await guestStore.inviteToSeat(
|
|
234
|
+
inviteeID: userId,
|
|
235
|
+
seatIndex: 0,
|
|
236
|
+
timeout: 30,
|
|
237
|
+
extraInfo: null,
|
|
238
|
+
);
|
|
239
|
+
if (result.isSuccess) {
|
|
240
|
+
debugPrint('Sent invitation to $userId, waiting for peer response...');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
2. **Listen for Audience Response**
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
Listen to the `onHostInvitationResponded` event via `HostListener`.
|
|
248
|
+
|
|
249
|
+
``` java
|
|
250
|
+
// Add to the HostListener configuration
|
|
251
|
+
_hostListener = HostListener(
|
|
252
|
+
onHostInvitationResponded: (isAccept, guestUser) {
|
|
253
|
+
if (isAccept) {
|
|
254
|
+
debugPrint('Audience ${guestUser.userName} accepted your invitation');
|
|
255
|
+
} else {
|
|
256
|
+
debugPrint('Audience ${guestUser.userName} refused your invitation');
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
);
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### Audience Side Implementation
|
|
263
|
+
1. **Receive Host Invitation**
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
Listen to the `onHostInvitationReceived` event via `GuestListener`.
|
|
267
|
+
|
|
268
|
+
``` java
|
|
269
|
+
// Add to the GuestListener configuration
|
|
270
|
+
_guestListener = GuestListener(
|
|
271
|
+
onHostInvitationReceived: (hostUser) {
|
|
272
|
+
debugPrint('Received mic connection invitation from Anchor ${hostUser.userName}');
|
|
273
|
+
// Pop up a dialog box for user selection between "Accept" or "Reject"
|
|
274
|
+
// showInvitationDialog(hostUser);
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
```
|
|
278
|
+
2. **Respond to invitation**
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
After the user makes a selection in the pop-up dialog box, call the method accordingly.
|
|
282
|
+
|
|
283
|
+
``` java
|
|
284
|
+
final String inviterId = "anchor ID who initiates invitation"; // obtain from onHostInvitationReceived event
|
|
285
|
+
|
|
286
|
+
// User clicks "Accept"
|
|
287
|
+
Future<void> accept() async {
|
|
288
|
+
final result = await guestStore.acceptInvitation(inviterId);
|
|
289
|
+
if (result.isSuccess) {
|
|
290
|
+
// Turn the mic on
|
|
291
|
+
// DeviceStore is the device management module provided by AtomicXCore, used for managing microphones, cameras and other physical devices.
|
|
292
|
+
// After accepting the invitation, turn on microphone to start collecting audio
|
|
293
|
+
DeviceStore.shared.openLocalMicrophone();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// User click "Reject"
|
|
298
|
+
Future<void> reject() async {
|
|
299
|
+
await guestStore.rejectInvitation(inviterId);
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Advanced Features
|
|
304
|
+
|
|
305
|
+
Once a user is on mic, the host may need to manage mic seats. The following features are primarily provided by `LiveSeatStore`, which functions with `CoGuestStore`.
|
|
306
|
+
|
|
307
|
+
### DeviceStore and LiveSeatStore Microphone Control Process
|
|
308
|
+
|
|
309
|
+
When using the seat feature, you need to understand the difference between `DeviceStore` and `LiveSeatStore` in microphone control:
|
|
310
|
+
- **DeviceStore**: Manage physical devices. `openLocalMicrophone` starts up the microphone device to perform audio capture. `closeLocalMicrophone` stops audio capture and releases the microphone device.
|
|
311
|
+
|
|
312
|
+
- **LiveSeatStore**: Manages seat business (i.e., audio stream). `muteMicrophone` mutes and stops sending local audio stream to the remote end, but the microphone device itself keeps running. `unmuteMicrophone` unmutes and restores sending audio stream to the remote end.
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
**Recommended workflow**: You should follow the principle of "open the device only once and use the mute switch for Anchor."
|
|
316
|
+
|
|
317
|
+
1. **When going on stage**: Once the audience succeeds in going on stage, call `openLocalMicrophone` only once to start the device.
|
|
318
|
+
|
|
319
|
+
2. **When on stage**: For all "unmute" and "mute" operations on the seat, users should call `unmuteMicrophone` and `muteMicrophone` to control the upstream audio stream.
|
|
320
|
+
|
|
321
|
+
3. **When going off stage**: When a user goes off stage (such as calling `disconnect`), call `closeLocalMicrophone` to release the device.
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
### On-Mic Users Control Their Own Microphone
|
|
325
|
+
|
|
326
|
+
On-mic users (including the host) can control their own microphone mute status via the `LiveSeatStore` interface.
|
|
327
|
+
|
|
328
|
+
#### Implementation:
|
|
329
|
+
1. **Mute**: Call the `muteMicrophone()` method. This is a one-way request with no callback.
|
|
330
|
+
|
|
331
|
+
2. **Unmute**: Call the `unmuteMicrophone()` method.
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
#### Example code:
|
|
335
|
+
``` java
|
|
336
|
+
final seatStore = LiveSeatStore.create(liveId);
|
|
337
|
+
|
|
338
|
+
seatStore.muteMicrophone(); // Mute
|
|
339
|
+
|
|
340
|
+
await seatStore.unmuteMicrophone(); // Unmute
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Host Remotely Controls On-Mic User’s Microphone
|
|
344
|
+
|
|
345
|
+
The host can perform "force mute" or "invite to unmute" operations on other on-mic users.
|
|
346
|
+
|
|
347
|
+
#### Implementation:
|
|
348
|
+
1. **Force Mute (Lock)**: The host calls `closeRemoteMicrophone` to forcibly mute the target user's microphone and lock their mic control. The muted user will receive the `onLocalMicrophoneClosedByAdmin` event via `liveSeatEventPublisher`, and their local "Open Microphone" button should become disabled.
|
|
349
|
+
|
|
350
|
+
2. **Invite to Unmute (Unlock)**: The host calls `openRemoteMicrophone`—this does not forcibly open the user's mic, but unlocks their mic control, allowing them to unmute themselves. The target user receives the `onLocalMicrophoneOpenedByAdmin` event, their "Open Microphone" button should become enabled, but they remain muted until they unmute themselves.
|
|
351
|
+
|
|
352
|
+
3. **User Unmutes Themselves**: After receiving the unlock notification, the user must actively call `LiveSeatStore`'s `unmuteMicrophone()` to actually unmute and be heard in the room.
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
#### Example code:
|
|
356
|
+
|
|
357
|
+
##### Host Side:
|
|
358
|
+
``` java
|
|
359
|
+
final seatStore = LiveSeatStore.create(liveId);
|
|
360
|
+
final String targetUserId = "userD";
|
|
361
|
+
|
|
362
|
+
// 1. Force mute userD and lock
|
|
363
|
+
final result1 = await seatStore.closeRemoteMicrophone(targetUserId);
|
|
364
|
+
if (result1.isSuccess) {
|
|
365
|
+
debugPrint('Muted and locked $targetUserId');
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// 2. Unlock userD's microphone permission (at this point userD remains muted)
|
|
369
|
+
final result2 = await seatStore.openRemoteMicrophone(
|
|
370
|
+
userID: targetUserId,
|
|
371
|
+
policy: DeviceControlPolicy.unlockOnly,
|
|
372
|
+
);
|
|
373
|
+
if (result2.isSuccess) {
|
|
374
|
+
debugPrint('Unlocked $targetUserId\'s microphone, user can unmute manually');
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
##### Audience Side:
|
|
379
|
+
``` java
|
|
380
|
+
late LiveSeatListener _seatListener;
|
|
381
|
+
|
|
382
|
+
// userD listens to the Anchor's operation
|
|
383
|
+
void subscribeSeatEvents() {
|
|
384
|
+
_seatListener = LiveSeatListener(
|
|
385
|
+
onLocalMicrophoneClosedByAdmin: () {
|
|
386
|
+
debugPrint('Muted by anchor');
|
|
387
|
+
// muteButton.isEnabled = false;
|
|
388
|
+
},
|
|
389
|
+
onLocalMicrophoneOpenedByAdmin: (policy) {
|
|
390
|
+
debugPrint('Anchor unmuted and unlocked');
|
|
391
|
+
// muteButton.isEnabled = true;
|
|
392
|
+
// muteButton.text = "Turn on microphone";
|
|
393
|
+
},
|
|
394
|
+
);
|
|
395
|
+
seatStore.addLiveSeatEventListener(_seatListener);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
@override
|
|
399
|
+
void dispose() {
|
|
400
|
+
seatStore.removeLiveSeatEventListener(_seatListener);
|
|
401
|
+
super.dispose();
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
#### CloseRemoteMicrophone API Parameter
|
|
406
|
+
<table>
|
|
407
|
+
<tr>
|
|
408
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
409
|
+
|
|
410
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
411
|
+
|
|
412
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
413
|
+
</tr>
|
|
414
|
+
|
|
415
|
+
<tr>
|
|
416
|
+
<td rowspan="1" colSpan="1" >`userID`</td>
|
|
417
|
+
|
|
418
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
419
|
+
|
|
420
|
+
<td rowspan="1" colSpan="1" >Operating user `userID`.</td>
|
|
421
|
+
</tr>
|
|
422
|
+
</table>
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
#### OpenRemoteMicrophone API Parameter
|
|
426
|
+
<table>
|
|
427
|
+
<tr>
|
|
428
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
429
|
+
|
|
430
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
431
|
+
|
|
432
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
433
|
+
</tr>
|
|
434
|
+
|
|
435
|
+
<tr>
|
|
436
|
+
<td rowspan="1" colSpan="1" >`userID`</td>
|
|
437
|
+
|
|
438
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
439
|
+
|
|
440
|
+
<td rowspan="1" colSpan="1" >Operating user `userID`.</td>
|
|
441
|
+
</tr>
|
|
442
|
+
|
|
443
|
+
<tr>
|
|
444
|
+
<td rowspan="1" colSpan="1" >`policy`</td>
|
|
445
|
+
|
|
446
|
+
<td rowspan="1" colSpan="1" >`DeviceControlPolicy`</td>
|
|
447
|
+
|
|
448
|
+
<td rowspan="1" colSpan="1" >Turn on microphone policy.</td>
|
|
449
|
+
</tr>
|
|
450
|
+
</table>
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
### Host Removes On-Mic User from the Seat
|
|
454
|
+
|
|
455
|
+
#### Implementation:
|
|
456
|
+
1. **Remove User from Mic**: The anchor can call the `kickUserOutOfSeat` method to force the specified user off the mic.
|
|
457
|
+
|
|
458
|
+
2. **Listen for Event Notification**: Users kicked off the mic will receive the `GuestListener``onKickedOffSeat` event notification.
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
#### Example code:
|
|
462
|
+
``` java
|
|
463
|
+
// Assume "userB" is to be kicked out
|
|
464
|
+
final String targetUserId = "userB";
|
|
465
|
+
final result = await seatStore.kickUserOutOfSeat(targetUserId);
|
|
466
|
+
if (result.isSuccess) {
|
|
467
|
+
debugPrint('Kicked $targetUserId off the mic');
|
|
468
|
+
} else {
|
|
469
|
+
debugPrint('Kick user failed: ${result.message}');
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// "userB" received the kicked off the mic event
|
|
473
|
+
_guestListener = GuestListener(
|
|
474
|
+
onKickedOffSeat: (seatIndex, hostUser) {
|
|
475
|
+
// Show a toast notification
|
|
476
|
+
debugPrint('You have been kicked off the mic by anchor');
|
|
477
|
+
},
|
|
478
|
+
);
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
#### KickUserOutOfSeat API Parameter
|
|
482
|
+
<table>
|
|
483
|
+
<tr>
|
|
484
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
485
|
+
|
|
486
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
487
|
+
|
|
488
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
489
|
+
</tr>
|
|
490
|
+
|
|
491
|
+
<tr>
|
|
492
|
+
<td rowspan="1" colSpan="1" >`userID`</td>
|
|
493
|
+
|
|
494
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
495
|
+
|
|
496
|
+
<td rowspan="1" colSpan="1" >The user kicked off the mic `userID`.</td>
|
|
497
|
+
</tr>
|
|
498
|
+
</table>
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
### Host Locks and Unlocks Mic Seats
|
|
502
|
+
|
|
503
|
+
The host can lock or unlock a specific mic seat.
|
|
504
|
+
|
|
505
|
+
#### Implementation:
|
|
506
|
+
1. **Lock Seat**: The anchor can call the `lockSeat` method to lock the seat with a specified index. Once locked, audiences cannot use `applyForSeat` or `takeSeat` to occupy the seat, but the anchor can invite an audience to the locked seat via `inviteToSeat`.
|
|
507
|
+
|
|
508
|
+
2. **Unlock Seat**: Call `unlockSeat` to unlock the seat. The seat can be occupied again after unlocking.
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
#### Example code:
|
|
512
|
+
``` java
|
|
513
|
+
// Lock seat 2
|
|
514
|
+
final result1 = await seatStore.lockSeat(2);
|
|
515
|
+
if (result1.isSuccess) {
|
|
516
|
+
debugPrint('Seat 2 locked');
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Unlock seat 2
|
|
520
|
+
final result2 = await seatStore.unlockSeat(2);
|
|
521
|
+
if (result2.isSuccess) {
|
|
522
|
+
debugPrint('Seat 2 unlocked');
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
#### LockSeat API Parameter
|
|
527
|
+
<table>
|
|
528
|
+
<tr>
|
|
529
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
530
|
+
|
|
531
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
532
|
+
|
|
533
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
534
|
+
</tr>
|
|
535
|
+
|
|
536
|
+
<tr>
|
|
537
|
+
<td rowspan="1" colSpan="1" >`seatIndex`</td>
|
|
538
|
+
|
|
539
|
+
<td rowspan="1" colSpan="1" >`int`</td>
|
|
540
|
+
|
|
541
|
+
<td rowspan="1" colSpan="1" >Index of the mic to lock.</td>
|
|
542
|
+
</tr>
|
|
543
|
+
</table>
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
#### UnlockSeat API Parameter
|
|
547
|
+
<table>
|
|
548
|
+
<tr>
|
|
549
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
550
|
+
|
|
551
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
552
|
+
|
|
553
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
554
|
+
</tr>
|
|
555
|
+
|
|
556
|
+
<tr>
|
|
557
|
+
<td rowspan="1" colSpan="1" >`seatIndex`</td>
|
|
558
|
+
|
|
559
|
+
<td rowspan="1" colSpan="1" >`int`</td>
|
|
560
|
+
|
|
561
|
+
<td rowspan="1" colSpan="1" >Index of the mic to unlock.</td>
|
|
562
|
+
</tr>
|
|
563
|
+
</table>
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
### Move Seat
|
|
567
|
+
|
|
568
|
+
Anchor and regular Microphone Users can call `moveUserToSeat` to move microphone positions.
|
|
569
|
+
|
|
570
|
+
#### Implementation:
|
|
571
|
+
1. **Host Moves User to Mic Seat**: The host can call this API to move any user to a specified seat. At this point, `userID` is the ID of the target user, `targetIndex` is the index of the target seat, and the `policy` parameter specifies the move strategy if the target seat is occupied. For details, see the [API parameter](https://write.woa.com/#moveusertoseat-.E6.8E.A5.E5.8F.A3.E5.8F.82.E6.95.B0.EF.BC.9A) description.
|
|
572
|
+
|
|
573
|
+
2. **On-Mic User Moves Themselves**: On-mic users can also call this API to move themselves. In this case, `userID` must be the user's own ID, `targetIndex` is the desired new seat index, and the `policy` parameter is ignored. If the target seat is occupied, the move fails with an error.
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
#### Example code:
|
|
577
|
+
``` java
|
|
578
|
+
final result = await seatStore.moveUserToSeat(
|
|
579
|
+
userID: "userC",
|
|
580
|
+
targetIndex: newSeatIndex,
|
|
581
|
+
policy: MoveSeatPolicy.abortWhenOccupied,
|
|
582
|
+
);
|
|
583
|
+
if (result.isSuccess) {
|
|
584
|
+
debugPrint('Successfully moved to seat $newSeatIndex');
|
|
585
|
+
} else {
|
|
586
|
+
debugPrint('Seat change failed, possibly seat is occupied');
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
#### MoveUserToSeat API Parameter
|
|
591
|
+
<table>
|
|
592
|
+
<tr>
|
|
593
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
594
|
+
|
|
595
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
596
|
+
|
|
597
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
598
|
+
</tr>
|
|
599
|
+
|
|
600
|
+
<tr>
|
|
601
|
+
<td rowspan="1" colSpan="1" >`userID`</td>
|
|
602
|
+
|
|
603
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
604
|
+
|
|
605
|
+
<td rowspan="1" colSpan="1" >The user who needs to move the mic `userID`.</td>
|
|
606
|
+
</tr>
|
|
607
|
+
|
|
608
|
+
<tr>
|
|
609
|
+
<td rowspan="1" colSpan="1" >`targetIndex`</td>
|
|
610
|
+
|
|
611
|
+
<td rowspan="1" colSpan="1" >`int`</td>
|
|
612
|
+
|
|
613
|
+
<td rowspan="1" colSpan="1" >Index of the target seat.</td>
|
|
614
|
+
</tr>
|
|
615
|
+
|
|
616
|
+
<tr>
|
|
617
|
+
<td rowspan="1" colSpan="1" >`policy`</td>
|
|
618
|
+
|
|
619
|
+
<td rowspan="1" colSpan="1" >`MoveSeatPolicy`</td>
|
|
620
|
+
|
|
621
|
+
<td rowspan="1" colSpan="1" >Processing policy when the target seat is occupied<br>- `abortWhenOccupied`: Abort movement when the target seat is occupied (default policy)<br>- `forceReplace`: Forcibly replace the user on the target seat. The replaced user will be kicked off the mic.<br>- `swapPosition`: Exchange with the user on the target seat.</td>
|
|
622
|
+
</tr>
|
|
623
|
+
</table>
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
## API documentation
|
|
627
|
+
|
|
628
|
+
For detailed information about ALL public interfaces, attributes, and methods of [CoGuestStore](https://tencent-rtc.github.io/TUIKit_Flutter/api_live_co_guest_store/CoGuestStore-class.html), [LiveSeatStore](https://tencent-rtc.github.io/TUIKit_Flutter/api_live_live_seat_store/LiveSeatStore-class.html), and its related classes, see the official API documentation of the [AtomicXCore](https://tencent-rtc.github.io/TUIKit_Flutter) framework. The related Store used in this guide is as follows:
|
|
629
|
+
<table>
|
|
630
|
+
<tr>
|
|
631
|
+
<td rowspan="1" colSpan="1" >**Store/Component**</td>
|
|
632
|
+
|
|
633
|
+
<td rowspan="1" colSpan="1" >**Feature Description**</td>
|
|
634
|
+
|
|
635
|
+
<td rowspan="1" colSpan="1" >**API Reference**</td>
|
|
636
|
+
</tr>
|
|
637
|
+
|
|
638
|
+
<tr>
|
|
639
|
+
<td rowspan="1" colSpan="1" >**CoGuestStore**</td>
|
|
640
|
+
|
|
641
|
+
<td rowspan="1" colSpan="1" >Audience co-broadcasting management: join microphone application/invite/consent/deny, member permission control (microphone/camera), state synchronization.</td>
|
|
642
|
+
|
|
643
|
+
<td rowspan="1" colSpan="1" >[API documentation](https://tencent-rtc.github.io/TUIKit_Flutter/api_live_co_guest_store/CoGuestStore-class.html)</td>
|
|
644
|
+
</tr>
|
|
645
|
+
|
|
646
|
+
<tr>
|
|
647
|
+
<td rowspan="1" colSpan="1" >**LiveSeatStore**</td>
|
|
648
|
+
|
|
649
|
+
<td rowspan="1" colSpan="1" >Seat management: mute/unmute, lock/unlock seats, remove speaker, remotely control Anchor microphone, listen to list status.</td>
|
|
650
|
+
|
|
651
|
+
<td rowspan="1" colSpan="1" >[API documentation](https://tencent-rtc.github.io/TUIKit_Flutter/api_live_live_seat_store/LiveSeatStore-class.html)</td>
|
|
652
|
+
</tr>
|
|
653
|
+
</table>
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
## FAQs
|
|
657
|
+
|
|
658
|
+
### What Is the Difference between Voice Room Co-Streaming and Live Streaming Co-Streaming
|
|
659
|
+
|
|
660
|
+
The main difference between both lies in business form and UI display:
|
|
661
|
+
- Live streaming: The core is video footage. You will use `LiveCoreWidget` as the core component to render the video stream of the Anchor and mic-connecting audience. The UI focuses on processing the layout and size of video footage, as well as adding 3D stickers (such as Nickname and placeholder image) on the video stream through `VideoViewDelegate`. You can turn on the camera and microphone at the same time.
|
|
662
|
+
|
|
663
|
+
- Voice room (voice chat room): The core is the seat grid. You will not use `LiveCoreWidget`, but build a grid UI (such as `GridView`) based on `LiveSeatStore`'s `liveSeatState` (especially `seatList`). The UI focuses on displaying each seat `SeatInfo` state in real time: whether there is a person, whether it is muted, whether it is locked, and whether speaking is ongoing. You only need to turn on microphone.
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
### How to Real-Time Refresh Seat Information on UI (Such As Whether There Is a Person, Whether Muted)
|
|
667
|
+
|
|
668
|
+
You should subscribe to the `seatList` property in `LiveSeatState`, which is a responsive data of `ValueListenable<List<SeatInfo>>` data type. It will notify you to re-render the microphone position list whenever the array changes. By traversing this array, you can:
|
|
669
|
+
- Get user information on the seat through `seatInfo.userInfo`.
|
|
670
|
+
|
|
671
|
+
- Check whether the seat is locked through `seatInfo.isLocked`.
|
|
672
|
+
|
|
673
|
+
- Check the mic status of the on-mic user through `seatInfo.userInfo.microphoneStatus`.
|
|
674
|
+
|
|
675
|
+
|