@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.
Files changed (54) hide show
  1. package/package.json +1 -1
  2. package/resource/doc/chatuikit/android/integration.md +499 -203
  3. package/resource/doc/chatuikit/android/workflow.md +713 -0
  4. package/resource/doc/chatuikit/flutter/integration.md +1 -1
  5. package/resource/doc/livekit/voice/android/voice-audience-list.md +334 -0
  6. package/resource/doc/livekit/voice/android/voice-audio-effect.md +380 -0
  7. package/resource/doc/livekit/voice/android/voice-barrage.md +565 -0
  8. package/resource/doc/livekit/voice/android/voice-co-guest-interaction.md +745 -0
  9. package/resource/doc/livekit/voice/android/voice-gift.md +822 -0
  10. package/resource/doc/livekit/voice/android/voice-host-interaction.md +703 -0
  11. package/resource/doc/livekit/voice/android/voice-integration.md +940 -0
  12. package/resource/doc/livekit/voice/android/voice-room-list.md +575 -0
  13. package/resource/doc/livekit/voice/flutter/voice-co-guest-interaction.md +675 -0
  14. package/resource/doc/livekit/voice/flutter/voice-integration.md +936 -0
  15. package/resource/doc/livekit/voice/ios/voice-audience-list.md +339 -0
  16. package/resource/doc/livekit/voice/ios/voice-audio-effect.md +370 -0
  17. package/resource/doc/livekit/voice/ios/voice-barrage.md +517 -0
  18. package/resource/doc/livekit/voice/ios/voice-co-guest-interaction.md +708 -0
  19. package/resource/doc/livekit/voice/ios/voice-gift.md +783 -0
  20. package/resource/doc/livekit/voice/ios/voice-host-interaction.md +770 -0
  21. package/resource/doc/livekit/voice/ios/voice-integration.md +898 -0
  22. package/resource/doc/livekit/voice/ios/voice-room-list.md +485 -0
  23. package/resource/doc/roomkit/vue/integration.md +179 -288
  24. package/resource/doc/roomkit/vue/workflow.md +499 -253
  25. package/resource/doc/tuicallkit/android/integration.md +539 -83
  26. package/resource/doc/tuicallkit/android/workflow.md +441 -0
  27. package/tools/common/present-scenario-choice.js +16 -0
  28. package/tools/common/present-scenario-choice.js.map +1 -0
  29. package/tools/definitions/get_native_call_uikit_integration_def.js +25 -9
  30. package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
  31. package/tools/definitions/get_native_chat_uikit_integration_def.js +36 -14
  32. package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
  33. package/tools/definitions/get_native_live_uikit_integration_def.js +55 -29
  34. package/tools/definitions/get_native_live_uikit_integration_def.js.map +1 -1
  35. package/tools/definitions/get_native_live_uikit_interaction_def.js +43 -54
  36. package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -1
  37. package/tools/definitions/get_web_room_feature_detail_def.js +52 -55
  38. package/tools/definitions/get_web_room_feature_detail_def.js.map +1 -1
  39. package/tools/definitions/get_web_room_uikit_integration_def.js +41 -25
  40. package/tools/definitions/get_web_room_uikit_integration_def.js.map +1 -1
  41. package/tools/definitions/present_scenario_choice_def.js +53 -0
  42. package/tools/definitions/present_scenario_choice_def.js.map +1 -0
  43. package/tools/definitions/record_prompt_def.js +26 -21
  44. package/tools/definitions/record_prompt_def.js.map +1 -1
  45. package/tools/definitions/record_result_def.js +20 -4
  46. package/tools/definitions/record_result_def.js.map +1 -1
  47. package/tools/index.js +2 -0
  48. package/tools/index.js.map +1 -1
  49. package/tools/live/get-native-live-uikit-integration.js +110 -34
  50. package/tools/live/get-native-live-uikit-integration.js.map +1 -1
  51. package/tools/live/get_native_live_uikit_interaction.js +128 -35
  52. package/tools/live/get_native_live_uikit_interaction.js.map +1 -1
  53. package/utils/report-cls-client.js +1 -1
  54. package/utils/report-es-client.js +1 -1
@@ -0,0 +1,898 @@
1
+ This document guides you through building a voice chat room application with host broadcasting and audience participation features using the **AtomicXCore** SDK's `LiveListStore` and `LiveSeatStore`.
2
+
3
+ ## Core Concepts
4
+ <table>
5
+ <tr>
6
+ <td rowspan="1" colSpan="1" >**Core Concept**</td>
7
+
8
+ <td rowspan="1" colSpan="1" >**Type**</td>
9
+
10
+ <td rowspan="1" colSpan="1" >**Core Responsibilities & Description**</td>
11
+ </tr>
12
+
13
+ <tr>
14
+ <td rowspan="1" colSpan="1" >`LiveListStore`</td>
15
+
16
+ <td rowspan="1" colSpan="1" >`class`</td>
17
+
18
+ <td rowspan="1" colSpan="1" >- `createLive()`: Start live stream as host.<br>- `endLive()`: End live stream as host.<br>- `joinLive()`: Audience joins live room.<br>- `leaveLive()`: Leave live room.</td>
19
+ </tr>
20
+
21
+ <tr>
22
+ <td rowspan="1" colSpan="1" >`LiveInfo`</td>
23
+
24
+ <td rowspan="1" colSpan="1" >`struct`</td>
25
+
26
+ <td rowspan="1" colSpan="1" >- `liveID`: Unique room identifier.<br>- `seatLayoutTemplateID`: Layout template ID (e.g., 600 for dynamic grid).</td>
27
+ </tr>
28
+
29
+ <tr>
30
+ <td rowspan="1" colSpan="1" >`LiveSeatStore`</td>
31
+
32
+ <td rowspan="1" colSpan="1" >`class`</td>
33
+
34
+ <td rowspan="1" colSpan="1" >- Core seat management class. Manages all seat information and seat-related operations in the room.<br>- Provides a real-time seat list data stream via liveSeatState.seatList.</td>
35
+ </tr>
36
+
37
+ <tr>
38
+ <td rowspan="1" colSpan="1" >`LiveSeatState`</td>
39
+
40
+ <td rowspan="1" colSpan="1" >`struct`</td>
41
+
42
+ <td rowspan="1" colSpan="1" >Represents the current state of all seats.<br>- `seatList`: a StateFlow containing the real-time seat list.<br>- `speakingUsers`: users currently speaking and their volume.</td>
43
+ </tr>
44
+
45
+ <tr>
46
+ <td rowspan="1" colSpan="1" >`SeatInfo`</td>
47
+
48
+ <td rowspan="1" colSpan="1" >`class`</td>
49
+
50
+ <td rowspan="1" colSpan="1" >Data model for a single seat. The seat list (seatList) emitted by LiveSeatStore is a list of SeatInfo objects.<br>Key fields:<br>- `index`: seat position.<br>- `isLocked`: whether the seat is locked.<br>- `userInfo`: user information for the seat. If the seat is empty, this field is empty.</td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <td rowspan="1" colSpan="1" >`SeatUserInfo`</td>
55
+
56
+ <td rowspan="1" colSpan="1" >`class`</td>
57
+
58
+ <td rowspan="1" colSpan="1" >Detailed data model for the user occupying a seat. When a user successfully takes a seat, the userInfo field in SeatInfo is populated.<br>Key fields:<br>- `userID`: unique user ID.<br>- `userName`: user nickname.<br>- `avatarURL`: user avatar URL.<br>- `microphoneStatus`: microphone status (on/off).<br>- `cameraStatus`: camera status (on/off).</td>
59
+ </tr>
60
+ </table>
61
+
62
+
63
+ ## Prerequisites
64
+
65
+ ### Step 1: Activate the Service
66
+
67
+ See [Activate Service](https://write.woa.com/document/141936672617742336) to obtain either the trial or paid version of the SDK.Then, go to [the Console](https://console.trtc.io/app) for application management, and get the following:
68
+ - `SDKAppID`: Application identifier (required). Tencent Cloud uses `SDKAppID` for billing and details.
69
+
70
+ - `SDKSecretKey`: Application secret key, used to initialize the configuration file with secret information.
71
+
72
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027182498/e0818e31c9f311f09e745254007c27c5.png)
73
+
74
+
75
+ ### Step 2: Import AtomicXCore into Your Project
76
+ 1. **Install the Component**: Add `pod 'AtomicXCore'` to your `Podfile`, then run `pod install`.
77
+
78
+ ``` ruby
79
+ target 'xxxx' do
80
+ pod 'AtomicXCore'
81
+ end
82
+ ```
83
+ 2. **Configure App Permissions**: Add camera and microphone usage descriptions to your app's `Info.plist` file.
84
+
85
+ ``` xml
86
+ <key>NSMicrophoneUsageDescription</key>
87
+ <string>TUILiveKit needs microphone permission to enable sound in recorded videos</string>
88
+ ```
89
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027182498/e07effb5c9f311f0a93d52540044a08e.png)
90
+
91
+
92
+ ### Step 3: Implement Login Logic
93
+
94
+ Call `LoginStore.shared.login` in your project to complete authentication. **This is required before using any functionality of AtomicXCore**.
95
+
96
+ > **Note:**
97
+ >
98
+
99
+ > We recommend calling LoginStore.shared.login only after your app's own user authentication is successful, to ensure clear and consistent login logic.
100
+ >
101
+
102
+ ``` swift
103
+ import AtomicXCore
104
+
105
+ // AppDelegate.swift
106
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
107
+ LoginStore.shared.login(sdkAppID: 1400000001, // Replace with your SDKAppID
108
+ userID: "test_001", // Replace with your UserID
109
+ userSig: "xxxxxxxxxxx") { result in // Replace with your UserSig
110
+ switch result {
111
+ case .success(let info):
112
+ debugPrint("login success")
113
+ case .failure(let error):
114
+ debugPrint("login failed code:\(error.code), message:\(error.message)")
115
+ }
116
+ }
117
+ return true
118
+ }
119
+ ```
120
+
121
+ **Login API Parameter Description**
122
+ <table>
123
+ <tr>
124
+ <td rowspan="1" colSpan="1" >Parameter</td>
125
+
126
+ <td rowspan="1" colSpan="1" >Type</td>
127
+
128
+ <td rowspan="1" colSpan="1" >Description</td>
129
+ </tr>
130
+
131
+ <tr>
132
+ <td rowspan="1" colSpan="1" >`sdkAppID`</td>
133
+
134
+ <td rowspan="1" colSpan="1" >`Int`</td>
135
+
136
+ <td rowspan="1" colSpan="1" >Get this from [TRTC console > Application management](https://console.trtc.io/app).</td>
137
+ </tr>
138
+
139
+ <tr>
140
+ <td rowspan="1" colSpan="1" >`userID`</td>
141
+
142
+ <td rowspan="1" colSpan="1" >`String`</td>
143
+
144
+ <td rowspan="1" colSpan="1" >The unique ID for the current user. Must contain only English letters, numbers, hyphens, and underscores.</td>
145
+ </tr>
146
+
147
+ <tr>
148
+ <td rowspan="1" colSpan="1" >`userSig`</td>
149
+
150
+ <td rowspan="1" colSpan="1" >`String`</td>
151
+
152
+ <td rowspan="1" colSpan="1" >A ticket for Tencent Cloud authentication. Please note:<br>- **Development Environment**: You can use the local `GenerateTestUserSig.genTestSig` function to generate a UserSig or generate a temporary UserSig via the [UserSig Generation Tool](https://console.trtc.io/usersig).<br>- **Production Environment**: To prevent key leakage, you must use a server-side method to generate UserSig. For details, see [Generating UserSig on the Server](https://write.woa.com/document/89644530319802368).<br>- For more information, see [How to Calculate and Use UserSig](https://write.woa.com/document/89644530319802368).</td>
153
+ </tr>
154
+ </table>
155
+
156
+
157
+ ## Building a Basic Voice Chat Room
158
+
159
+ ### Step 1: Host Room Creation
160
+
161
+ Follow these steps to quickly set up a voice chat room as the host.
162
+
163
+ #### **1. Initialize the Seat Store**
164
+
165
+ In your host `ViewController`, instantiate `LiveSeatStore`. Use the Combine framework to observe changes in `liveSeatStore.state` for real-time seat updates and UI rendering.
166
+ ``` swift
167
+ import UIKit
168
+ import AtomicXCore
169
+ import Combine
170
+
171
+ class YourAnchorViewController: UIViewController {
172
+
173
+ private let liveListStore = LiveListStore.shared
174
+ private let deviceStore = DeviceStore.shared
175
+
176
+ // Initialize LiveSeatStore with liveID
177
+ private let liveID = "test_voice_room_001"
178
+ private lazy var liveSeatStore = LiveSeatStore.create(liveID: liveID)
179
+
180
+ // Manage subscription lifecycle
181
+ private var cancellables = Set<AnyCancellable>()
182
+
183
+ override func viewDidLoad() {
184
+ super.viewDidLoad()
185
+ // Initialize your layout here
186
+ // setupUI()
187
+
188
+ // Listen for seat list changes
189
+ observeSeatList()
190
+ }
191
+
192
+ private func observeSeatList() {
193
+ // Subscribe to seat list updates and refresh seat UI
194
+ liveSeatStore.state
195
+ .subscribe(StatePublisherSelector(keyPath: \LiveSeatState.seatList))
196
+ .removeDuplicates()
197
+ .receive(on: DispatchQueue.main)
198
+ .sink { [weak self] seatInfoList in
199
+ // Update seat UI with seatInfoList
200
+ // Example: self?.updateMicSeatView(seatInfoList)
201
+ print("Seat list updated: \(seatInfoList.count) seats")
202
+ }
203
+ .store(in: &cancellables)
204
+ }
205
+ }
206
+ ```
207
+
208
+ #### **2. **Turn On Microphone
209
+
210
+ Turn On Microphone by calling `openLocalMicrophone` from `DeviceStore`:
211
+ ``` swift
212
+ import UIKit
213
+ import AtomicXCore
214
+
215
+ class YourAnchorViewController: UIViewController {
216
+ // ... other code ...
217
+
218
+ private func openDevices() {
219
+ DeviceStore.shared.openLocalMicrophone(completion: nil)
220
+ }
221
+ }
222
+ ```
223
+
224
+ #### **3. Start Voice Chat**
225
+
226
+ Start the voice chat room by invoking `createLive` on `LiveListStore`:
227
+ ``` swift
228
+ import UIKit
229
+ import AtomicXCore
230
+
231
+ class YourAnchorViewController: UIViewController {
232
+ // ... other code ...
233
+ private let liveID = "test_voice_room_001"
234
+
235
+ override func viewDidLoad() {
236
+ super.viewDidLoad()
237
+ // ... other code ...
238
+
239
+ // Start voice chat
240
+ startLive()
241
+ }
242
+
243
+ private func startLive() {
244
+ var liveInfo = LiveInfo()
245
+
246
+ liveInfo.liveID = liveID
247
+ liveInfo.liveName = "test voice chat room"
248
+ liveInfo.isSeatEnabled = true
249
+ liveInfo.keepOwnerOnSeat = true
250
+ liveInfo.seatLayoutTemplateID = 70 // Use correct ID per product spec
251
+ liveInfo.seatMode = .apply
252
+ liveInfo.maxSeatCount = 10
253
+
254
+ liveListStore.createLive(liveInfo) { [weak self] result in
255
+ guard let self = self else { return }
256
+ switch result {
257
+ case .success(let liveInfo):
258
+ print("Response startLive onSuccess")
259
+ // Host is on seat by default; unmute microphone if needed
260
+ liveSeatStore.unmuteMicrophone(completion: nil)
261
+ case .failure(let errorInfo):
262
+ print("Response startLive onError: \(errorInfo.message)")
263
+ }
264
+ }
265
+ }
266
+ }
267
+ ```
268
+
269
+ **LiveInfo Parameter Reference:**
270
+ <table>
271
+ <tr>
272
+ <td rowspan="1" colSpan="1" >**Parameter Name**</td>
273
+
274
+ <td rowspan="1" colSpan="1" >**Type**</td>
275
+
276
+ <td rowspan="1" colSpan="1" >**Required**</td>
277
+
278
+ <td rowspan="1" colSpan="1" >**Description**</td>
279
+ </tr>
280
+
281
+ <tr>
282
+ <td rowspan="1" colSpan="1" >`liveID`</td>
283
+
284
+ <td rowspan="1" colSpan="1" >`String`</td>
285
+
286
+ <td rowspan="1" colSpan="1" >Required</td>
287
+
288
+ <td rowspan="1" colSpan="1" >Unique identifier for the live room</td>
289
+ </tr>
290
+
291
+ <tr>
292
+ <td rowspan="1" colSpan="1" >`liveName`</td>
293
+
294
+ <td rowspan="1" colSpan="1" >`String`</td>
295
+
296
+ <td rowspan="1" colSpan="1" >Optional</td>
297
+
298
+ <td rowspan="1" colSpan="1" >Room title</td>
299
+ </tr>
300
+
301
+ <tr>
302
+ <td rowspan="1" colSpan="1" >`notice`</td>
303
+
304
+ <td rowspan="1" colSpan="1" >`String`</td>
305
+
306
+ <td rowspan="1" colSpan="1" >Optional</td>
307
+
308
+ <td rowspan="1" colSpan="1" >Room announcement</td>
309
+ </tr>
310
+
311
+ <tr>
312
+ <td rowspan="1" colSpan="1" >`isMessageDisable`</td>
313
+
314
+ <td rowspan="1" colSpan="1" >`Bool`</td>
315
+
316
+ <td rowspan="1" colSpan="1" >Optional</td>
317
+
318
+ <td rowspan="1" colSpan="1" >Mute chat (`true`: muted, `false`: not muted)</td>
319
+ </tr>
320
+
321
+ <tr>
322
+ <td rowspan="1" colSpan="1" >`isPublicVisible`</td>
323
+
324
+ <td rowspan="1" colSpan="1" >`Bool`</td>
325
+
326
+ <td rowspan="1" colSpan="1" >Optional</td>
327
+
328
+ <td rowspan="1" colSpan="1" >Public visibility (`true`: visible, `false`: not visible)</td>
329
+ </tr>
330
+
331
+ <tr>
332
+ <td rowspan="1" colSpan="1" >`isSeatEnabled`</td>
333
+
334
+ <td rowspan="1" colSpan="1" >`Bool`</td>
335
+
336
+ <td rowspan="1" colSpan="1" >Optional</td>
337
+
338
+ <td rowspan="1" colSpan="1" >Enable seat feature (`true`: enabled, `false`: disabled)</td>
339
+ </tr>
340
+
341
+ <tr>
342
+ <td rowspan="1" colSpan="1" >`keepOwnerOnSeat`</td>
343
+
344
+ <td rowspan="1" colSpan="1" >`Bool`</td>
345
+
346
+ <td rowspan="1" colSpan="1" >Optional</td>
347
+
348
+ <td rowspan="1" colSpan="1" >Keep host on seat</td>
349
+ </tr>
350
+
351
+ <tr>
352
+ <td rowspan="1" colSpan="1" >`maxSeatCount`</td>
353
+
354
+ <td rowspan="1" colSpan="1" >`Int`</td>
355
+
356
+ <td rowspan="1" colSpan="1" >Required</td>
357
+
358
+ <td rowspan="1" colSpan="1" >Maximum number of seats</td>
359
+ </tr>
360
+
361
+ <tr>
362
+ <td rowspan="1" colSpan="1" >`seatMode`</td>
363
+
364
+ <td rowspan="1" colSpan="1" >`TakeSeatMode`</td>
365
+
366
+ <td rowspan="1" colSpan="1" >Optional</td>
367
+
368
+ <td rowspan="1" colSpan="1" >Seat mode (`.free`: free seat, `.apply`: apply for seat)</td>
369
+ </tr>
370
+
371
+ <tr>
372
+ <td rowspan="1" colSpan="1" >`seatLayoutTemplateID`</td>
373
+
374
+ <td rowspan="1" colSpan="1" >`UInt`</td>
375
+
376
+ <td rowspan="1" colSpan="1" >Required</td>
377
+
378
+ <td rowspan="1" colSpan="1" >Seat layout template ID</td>
379
+ </tr>
380
+
381
+ <tr>
382
+ <td rowspan="1" colSpan="1" >`coverURL`</td>
383
+
384
+ <td rowspan="1" colSpan="1" >`String`</td>
385
+
386
+ <td rowspan="1" colSpan="1" >Optional</td>
387
+
388
+ <td rowspan="1" colSpan="1" >Room cover image URL</td>
389
+ </tr>
390
+
391
+ <tr>
392
+ <td rowspan="1" colSpan="1" >`backgroundURL`</td>
393
+
394
+ <td rowspan="1" colSpan="1" >`String`</td>
395
+
396
+ <td rowspan="1" colSpan="1" >Optional</td>
397
+
398
+ <td rowspan="1" colSpan="1" >Room background image URL</td>
399
+ </tr>
400
+
401
+ <tr>
402
+ <td rowspan="1" colSpan="1" >`categoryList`</td>
403
+
404
+ <td rowspan="1" colSpan="1" >`[NSNumber]`</td>
405
+
406
+ <td rowspan="1" colSpan="1" >Optional</td>
407
+
408
+ <td rowspan="1" colSpan="1" >Room category tags</td>
409
+ </tr>
410
+
411
+ <tr>
412
+ <td rowspan="1" colSpan="1" >`activityStatus`</td>
413
+
414
+ <td rowspan="1" colSpan="1" >`Int`</td>
415
+
416
+ <td rowspan="1" colSpan="1" >Optional</td>
417
+
418
+ <td rowspan="1" colSpan="1" >Live activity status</td>
419
+ </tr>
420
+
421
+ <tr>
422
+ <td rowspan="1" colSpan="1" >`isGiftEnabled`</td>
423
+
424
+ <td rowspan="1" colSpan="1" >`Bool`</td>
425
+
426
+ <td rowspan="1" colSpan="1" >Optional</td>
427
+
428
+ <td rowspan="1" colSpan="1" >Enable gift feature (`true`: enabled, `false`: disabled)</td>
429
+ </tr>
430
+ </table>
431
+
432
+
433
+ #### **4. Build the Mic Seat UI**
434
+
435
+ > **Note:**
436
+ >
437
+
438
+ > For seat UI logic and effects, refer to the open-source [SeatGridView.swift](https://github.com/Tencent-RTC/TUIKit_iOS/blob/main/live/Sources/SeatGridview/SeatGridView.swift) in TUILiveKit.
439
+ >
440
+
441
+
442
+ Use your `LiveSeatStore` instance to subscribe to `state.seatList` and update the UI in real time:
443
+ ``` swift
444
+ import UIKit
445
+ import AtomicXCore
446
+ import Combine
447
+
448
+ class YourAnchorViewController: UIViewController {
449
+ // ... other code ...
450
+ private var cancellables = Set<AnyCancellable>()
451
+ private lazy var liveSeatStore = LiveSeatStore.create(liveID: "your_live_id")
452
+
453
+ override func viewDidLoad() {
454
+ super.viewDidLoad()
455
+ // ... other code ...
456
+
457
+ observeSeatList()
458
+ }
459
+
460
+ private func observeSeatList() {
461
+ liveSeatStore.state
462
+ .subscribe(StatePublisherSelector(keyPath: \LiveSeatState.seatList))
463
+ .removeDuplicates()
464
+ .receive(on: DispatchQueue.main)
465
+ .sink { [weak self] seatInfoList in
466
+ // seatInfoList contains the latest seat data
467
+ print("Seat list updated: \(seatInfoList.count) seats")
468
+ }
469
+ .store(in: &cancellables)
470
+ }
471
+ }
472
+ ```
473
+
474
+ #### **5. End Voice Chat**
475
+
476
+ To end the session, call `endLive` on `LiveListStore`. The SDK will handle stream termination and room cleanup.
477
+ ``` swift
478
+ import UIKit
479
+ import AtomicXCore
480
+ import RTCRoomEngine
481
+
482
+ class YourAnchorViewController: UIViewController {
483
+ // ... other code ...
484
+
485
+ private func stopLive() {
486
+ liveListStore.endLive { result in
487
+ switch result {
488
+ case .success(let data):
489
+ print("endLive success")
490
+ case .failure(let errorInfo):
491
+ print("endLive error: \(errorInfo.message)")
492
+ }
493
+ }
494
+ }
495
+ }
496
+ ```
497
+
498
+ ### Step 2: Audience Joins the Voice Chat Room
499
+
500
+ Enable audience members to join the voice chat room with the following steps.
501
+
502
+ #### **1. Initialize the Seat Store**
503
+
504
+ In your audience `ViewController`, instantiate `LiveSeatStore` and subscribe to `state.seatList` for seat UI updates.
505
+ ``` swift
506
+ import UIKit
507
+ import AtomicXCore
508
+ import Combine
509
+
510
+ class YourAudienceViewController: UIViewController {
511
+
512
+ private let liveListStore = LiveListStore.shared
513
+
514
+ // Use the same liveID as the host
515
+ private let liveID = "test_voice_room_001"
516
+ private lazy var liveSeatStore = LiveSeatStore.create(liveID: liveID)
517
+
518
+ private var cancellables = Set<AnyCancellable>()
519
+
520
+ override func viewDidLoad() {
521
+ super.viewDidLoad()
522
+ // Initialize your layout here
523
+ // setupUI()
524
+
525
+ observeSeatList()
526
+ }
527
+
528
+ private func observeSeatList() {
529
+ liveSeatStore.state
530
+ .subscribe(StatePublisherSelector(keyPath: \LiveSeatState.seatList))
531
+ .removeDuplicates()
532
+ .receive(on: DispatchQueue.main)
533
+ .sink { [weak self] seatInfoList in
534
+ // Update seat UI with seatInfoList
535
+ // Example: self?.updateMicSeatView(seatInfoList)
536
+ print("AudienceVC Seat list updated: \(seatInfoList.count) seats")
537
+ }
538
+ .store(in: &cancellables)
539
+ }
540
+ }
541
+ ```
542
+
543
+ #### **2. Join the Voice Chat Room**
544
+
545
+ Join the room by calling `joinLive` on `LiveListStore`:
546
+ ``` swift
547
+ import UIKit
548
+ import AtomicXCore
549
+
550
+ class YourAudienceViewController: UIViewController {
551
+
552
+ // ... other code ...
553
+ override func viewDidLoad() {
554
+ super.viewDidLoad()
555
+ // ... other code ...
556
+
557
+ joinLive()
558
+ }
559
+
560
+ private func joinLive() {
561
+ liveListStore.joinLive(liveID: liveID) { result in
562
+ DispatchQueue.main.async {
563
+ switch result {
564
+ case .success(let liveInfo):
565
+ print("joinLive success")
566
+ case .failure(let errorInfo):
567
+ print("joinLive error: \(errorInfo.message)")
568
+ }
569
+ }
570
+ }
571
+ }
572
+ }
573
+ ```
574
+
575
+ #### **3. Build the Mic Seat UI**
576
+
577
+ Building the seat UI for audience members is identical to the host process. Refer to the host [Build the Mic Seat UI.](https://write.woa.com/#15f887ab-f1bb-41ec-9143-c1e791d875fb)
578
+
579
+ #### **4. Leave the Voice Chat Room**
580
+
581
+ To leave the room, call `leaveLive` on `LiveListStore`:
582
+ ``` swift
583
+ import UIKit
584
+ import AtomicXCore
585
+
586
+ class YourAudienceViewController: UIViewController {
587
+ // ... other code ...
588
+
589
+ private func leaveLive() {
590
+ liveListStore.leaveLive { result in
591
+ switch result {
592
+ case .success:
593
+ print("leaveLive success")
594
+ case .failure(let errorInfo):
595
+ print("leaveLive error: \(errorInfo.message)")
596
+ }
597
+ }
598
+ }
599
+ }
600
+ ```
601
+
602
+ ### Run and Test
603
+
604
+ After completing these steps, you will have a functional voice chat live streaming room. For advanced features, see "Enriching Voice Chat Room Scenarios" below.
605
+
606
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027182498/a05436e9c9f511f09e745254007c27c5.png)
607
+
608
+ ## Advanced Features
609
+
610
+ ### Implementing Speaking Wave Animation for Users on Seat
611
+
612
+ In voice chat rooms, it's common to show a wave animation over the avatar of users who are currently speaking. `LiveSeatStore` provides a `speakingUsers` stream for this purpose.
613
+
614
+ #### Example
615
+
616
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027182498/3e599bf8c9f711f0a4a55254001c06ec.gif)
617
+
618
+
619
+ #### Implementation
620
+
621
+ > **Note:**
622
+ >
623
+
624
+ > For a complete implementation of the speaking wave animation, refer to [SeatGridView.swift](https://github.com/Tencent-RTC/TUIKit_iOS/blob/main/live/Sources/SeatGridview/SeatGridView.swift) in TUILiveKit.
625
+ >
626
+
627
+
628
+ In your `YourAnchorViewController` or `YourAudienceViewController`, subscribe to `speakingUsers` and update the UI accordingly:
629
+ ``` swift
630
+ import UIKit
631
+ import AtomicXCore
632
+ import Combine
633
+
634
+ class YourAnchorViewController: UIViewController {
635
+ // ... (other code omitted) ...
636
+ private var cancellables = Set<AnyCancellable>()
637
+
638
+ override func viewDidLoad() {
639
+ super.viewDidLoad()
640
+ // ... (other code omitted) ...
641
+
642
+ observeSpeakingUsersState()
643
+ }
644
+
645
+ private func observeSpeakingUsersState() {
646
+ liveSeatStore.state
647
+ .subscribe(StatePublisherSelector(keyPath: \LiveSeatState.speakingUsers))
648
+ .removeDuplicates()
649
+ .receive(on: DispatchQueue.main)
650
+ .sink { [weak self] speakingUserMap in
651
+ // Update UI to indicate which users are speaking
652
+ print("Speaking users updated: \(speakingUserMap.count) users")
653
+ }
654
+ .store(in: &cancellables)
655
+ }
656
+ }
657
+ ```
658
+
659
+ ### Synchronizing Custom Status in Live Streaming Room
660
+
661
+ In live streaming room, the host may need to synchronize custom information to all audience members, such as "current room topic" or "background music info". Use the `metaData` feature of LiveListStore to achieve this.
662
+
663
+ #### Implementation
664
+ 1. On the host side, set custom information (recommended as JSON) to one or more keys using the `updateLiveMetaData` API. AtomicXCore will synchronize these changes in real time to all audience members.
665
+
666
+ 2. On the audience side, subscribe to `LiveListState.currentLive` and listen for changes in `metaData`. When a relevant key is updated, parse its value and update your business state.
667
+
668
+
669
+ #### Code Example
670
+ ``` swift
671
+ import AtomicXCore
672
+ import Combine
673
+
674
+ // 1. Define a background music model (recommended: Codable)
675
+ struct MusicModel: Codable {
676
+ let musicId: String
677
+ let musicName: String
678
+ }
679
+
680
+ // 2. Host side: Push background music info
681
+ func updateBackgroundMusic(music: MusicModel) {
682
+ guard let jsonData = try? JSONEncoder().encode(music),
683
+ let jsonString = String(data: jsonData, encoding: .utf8) else { return }
684
+
685
+ let metaData = ["music_info": jsonString]
686
+
687
+ LiveListStore.shared.updateLiveMetaData(metaData) { result in
688
+ if case .success = result {
689
+ print("Background music \(music.musicName) pushed successfully")
690
+ } else if case .failure(let error) = result {
691
+ print("Background music push failed: \(error.message)")
692
+ }
693
+ }
694
+ }
695
+
696
+ // 3. Audience side: Subscribe and update business logic
697
+ private func subscribeToDataUpdates() {
698
+ LiveListStore.shared.state
699
+ // Listen for metaData changes in the current room
700
+ .subscribe(StatePublisherSelector(keyPath: \LiveListState.currentLive))
701
+ .map { $0.metaData["music_info"] }
702
+ .removeDuplicates()
703
+ .receive(on: DispatchQueue.main)
704
+ .sink { jsonString in
705
+ guard let jsonString = jsonString,
706
+ let data = jsonString.data(using: .utf8),
707
+ let music = try? JSONDecoder().decode(MusicModel.self, from: data) else {
708
+ return
709
+ }
710
+ // Update business state, play new music
711
+ // ... (e.g.: playMusic(music))
712
+ }
713
+ .store(in: &cancellables)
714
+ }
715
+ ```
716
+
717
+ ## Enriching Voice Chat Room Scenarios
718
+
719
+ After implementing the basic voice chat room, enhance your application with the following features:
720
+ <table>
721
+ <tr>
722
+ <td rowspan="1" colSpan="1" >**Feature**</td>
723
+
724
+ <td rowspan="1" colSpan="1" >**Description**</td>
725
+
726
+ <td rowspan="1" colSpan="1" >**Store**</td>
727
+
728
+ <td rowspan="1" colSpan="1" >**Implementation Guide**</td>
729
+ </tr>
730
+
731
+ <tr>
732
+ <td rowspan="1" colSpan="1" >**Audience Take Seat**</td>
733
+
734
+ <td rowspan="1" colSpan="1" >Audience members can apply to take a seat and interact with the host in real time.</td>
735
+
736
+ <td rowspan="1" colSpan="1" >[CoGuestStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/cogueststore)</td>
737
+
738
+ <td rowspan="1" colSpan="1" >[Implementation](https://write.woa.com/document/194571595735859200)</td>
739
+ </tr>
740
+
741
+ <tr>
742
+ <td rowspan="1" colSpan="1" >**Host Cross-Room PK**</td>
743
+
744
+ <td rowspan="1" colSpan="1" >Hosts from different rooms can connect for interaction or PK.</td>
745
+
746
+ <td rowspan="1" colSpan="1" >[CoHostStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/cohoststore)<br>[BattleStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/battlestore)</td>
747
+
748
+ <td rowspan="1" colSpan="1" >[Implementation](https://write.woa.com/document/194571595881611264)</td>
749
+ </tr>
750
+
751
+ <tr>
752
+ <td rowspan="1" colSpan="1" >**Add Barrage Chat**</td>
753
+
754
+ <td rowspan="1" colSpan="1" >Room members can send and receive real-time text messages.</td>
755
+
756
+ <td rowspan="1" colSpan="1" >[BarrageStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/barragestore)</td>
757
+
758
+ <td rowspan="1" colSpan="1" >[Implementation](https://write.woa.com/document/195218523643924480)</td>
759
+ </tr>
760
+
761
+ <tr>
762
+ <td rowspan="1" colSpan="1" >**Gift System**</td>
763
+
764
+ <td rowspan="1" colSpan="1" >Audience can send virtual gifts to hosts to increase interaction and engagement.</td>
765
+
766
+ <td rowspan="1" colSpan="1" >[GiftStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/giftstore)</td>
767
+
768
+ <td rowspan="1" colSpan="1" >[Implementation](https://write.woa.com/document/195218406733824000)</td>
769
+ </tr>
770
+ </table>
771
+
772
+
773
+ ## API Documentation
774
+ <table>
775
+ <tr>
776
+ <td rowspan="1" colSpan="1" >**Store/Component**</td>
777
+
778
+ <td rowspan="1" colSpan="1" >**Description**</td>
779
+
780
+ <td rowspan="1" colSpan="1" >**API Docs**</td>
781
+ </tr>
782
+
783
+ <tr>
784
+ <td rowspan="1" colSpan="1" >`LiveListStore`</td>
785
+
786
+ <td rowspan="1" colSpan="1" >Manages the full live room lifecycle: create, join, leave, destroy room; query room list; modify room info; listen for room status changes.</td>
787
+
788
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveliststore)</td>
789
+ </tr>
790
+
791
+ <tr>
792
+ <td rowspan="1" colSpan="1" >`LiveSeatStore`</td>
793
+
794
+ <td rowspan="1" colSpan="1" >Seat management: handle seat list, user status, seat operations (take seat, leave seat, kick, lock, toggle mic/camera), and seat events.</td>
795
+
796
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveseatstore)</td>
797
+ </tr>
798
+
799
+ <tr>
800
+ <td rowspan="1" colSpan="1" >`DeviceStore`</td>
801
+
802
+ <td rowspan="1" colSpan="1" >Audio/video device control: microphone, camera, screen sharing, device status monitoring.</td>
803
+
804
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore/)</td>
805
+ </tr>
806
+
807
+ <tr>
808
+ <td rowspan="1" colSpan="1" >`CoGuestStore`</td>
809
+
810
+ <td rowspan="1" colSpan="1" >Audience co-host management: application, invitation, acceptance, rejection, member permissions, status sync.</td>
811
+
812
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/cogueststore/)</td>
813
+ </tr>
814
+
815
+ <tr>
816
+ <td rowspan="1" colSpan="1" >`CoHostStore`</td>
817
+
818
+ <td rowspan="1" colSpan="1" >Host cross-room connection: supports multiple layouts, initiate/accept/reject connection, manage co-host interaction.</td>
819
+
820
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/cohoststore/)</td>
821
+ </tr>
822
+
823
+ <tr>
824
+ <td rowspan="1" colSpan="1" >`BattleStore`</td>
825
+
826
+ <td rowspan="1" colSpan="1" >Host PK battle: initiate PK, manage PK status, synchronize scores, listen for battle results.</td>
827
+
828
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/battlestore)</td>
829
+ </tr>
830
+
831
+ <tr>
832
+ <td rowspan="1" colSpan="1" >`GiftStore`</td>
833
+
834
+ <td rowspan="1" colSpan="1" >Gift interaction: fetch gift list, send/receive gifts, listen for gift events.</td>
835
+
836
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/giftstore/)</td>
837
+ </tr>
838
+
839
+ <tr>
840
+ <td rowspan="1" colSpan="1" >`BarrageStore`</td>
841
+
842
+ <td rowspan="1" colSpan="1" >Barrage (chat overlay): send text/custom barrage, maintain barrage list, monitor barrage status.</td>
843
+
844
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/barragestore)</td>
845
+ </tr>
846
+
847
+ <tr>
848
+ <td rowspan="1" colSpan="1" >`LikeStore`</td>
849
+
850
+ <td rowspan="1" colSpan="1" >Like interaction: send likes, listen for like events, synchronize like count.</td>
851
+
852
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/likestore)</td>
853
+ </tr>
854
+
855
+ <tr>
856
+ <td rowspan="1" colSpan="1" >`LiveAudienceStore`</td>
857
+
858
+ <td rowspan="1" colSpan="1" >Audience management: get real-time audience list, count, entry/exit events.</td>
859
+
860
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveaudiencestore)</td>
861
+ </tr>
862
+
863
+ <tr>
864
+ <td rowspan="1" colSpan="1" >`AudioEffectStore`</td>
865
+
866
+ <td rowspan="1" colSpan="1" >Audio effects: voice change, reverb, in-ear monitoring, effect switching.</td>
867
+
868
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/audioeffectstore)</td>
869
+ </tr>
870
+
871
+ <tr>
872
+ <td rowspan="1" colSpan="1" >`BaseBeautyStore`</td>
873
+
874
+ <td rowspan="1" colSpan="1" >Basic beauty: adjust smoothing/whitening/redness (0-100), reset beauty status, synchronize effect parameters.</td>
875
+
876
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/basebeautystore)</td>
877
+ </tr>
878
+ </table>
879
+
880
+
881
+ ## FAQs
882
+
883
+ ### Why is there no sound after the audience calls joinLive?
884
+ - **Check device permissions**: Ensure your app declares and requests microphone access (`NSMicrophoneUsageDescription`) in `Info.plist`.
885
+
886
+ - **Check host configuration**: Verify the host has enabled the microphone via `DeviceStore.shared.openLocalMicrophone(completion: nil)`.
887
+
888
+ - **Check network**: Confirm the device has a stable network connection.
889
+
890
+
891
+ ### Why is the seat list not displayed or not updating?
892
+ - **Check store initialization**: Confirm you create the `LiveSeatStore` instance (`LiveSeatStore.create(liveID: liveID)`) with the same `liveID` before calling `createLive` or `joinLive`.
893
+
894
+ - **Check data subscription**: Make sure you use Combine to subscribe to `liveSeatStore.state.seatList`, and the `cancellables` lifecycle matches your `ViewController`.
895
+
896
+ - **Check API calls**: Ensure `createLive` (host) or `joinLive` (audience) was called successfully (check the `.success` branch in `switch result`).
897
+
898
+