Live Preview | Live Viewing | Live Interaction |
![]() |
![]() | ![]() |
TUILiveKit trial version or activate the paid version.import { LiveInfo } from '@tencentcloud/atomicxcore'import { PlayerStatus, PlayerView, PlayerViewController } from 'tuilivekit'@Entry@Componentstruct AudiencePlayerPage {liveID: string = ''onBack?: () => voidprivate controller: PlayerViewController = new PlayerViewController()private unsubscribeStatus?: () => voidaboutToAppear(): void {// 1. Set live room info (must be called before startPlay / joinChannel)const liveInfo = new LiveInfo()liveInfo.liveID = this.liveIDthis.controller.setLiveInfo(liveInfo)// 2. Listen for close and enter room eventsthis.controller.onCloseClicked = () => this.onBack?.()this.controller.onJoinLiveClicked = () => console.info(`join live: ${this.liveID}`)// 3. (Optional) Listen for playback status changes, returns an unsubscribe closurethis.unsubscribeStatus = this.controller.status((status: PlayerStatus) => {console.info(`player status: ${status}`)})// 4. Start stream playbackthis.controller.startPlay()// 5. Join the live room. Only after successful entry can the audience send live comments, likes, gifts, or request co-hostingthis.controller.joinChannel().then((info: LiveInfo) => {console.info(`joinChannel success: ${info.liveID}`)}).catch((error: Error) => {console.error(`joinChannel failed: ${error.message}`)})}aboutToDisappear(): void {// 6. On page destroy, unsubscribe, stop playback, and leave the live roomthis.unsubscribeStatus?.()this.controller.stopPlay()this.controller.leaveChannel()}build() {PlayerView({ controller: this.controller })}}
this.navigationStack.pushPath({ name: 'singlePlayer', param: liveID })
Property | Description |
controller | PlayerViewController, the entry point for playback control. If not provided, the component creates its own controller. |
Method / Property | Description |
setLiveInfo(liveInfo: LiveInfo) | Set live room information. Must be called before startPlay or joinChannel. When switching rooms, the component will stop playback and leave the previous room first. |
startPlay() | Start stream playback (only plays the stream, not yet entered the room). |
stopPlay() | Stop stream playback. |
joinChannel(): Promise | Enter the live room. Returns room info on success. Only after entering can the audience send live comments, likes, gifts, or request co-hosting. |
leaveChannel(): Promise | Leave the live room. |
setVolume(volume: number) | Set playback volume, value range 0 ~ 100. |
joinLiveEntranceEnabled | Whether to show the Enter Room entry. |
status(listener) | Subscribe to playback status, returns an unsubscribe closure. The current status is immediately called back on subscription. |
liveID | The ID of the currently viewed live room. |
onCloseClicked | Callback when the audience clicks the close button (the component will leave the room before the callback). |
onJoinLiveClicked | Callback when the audience successfully enters the room via the Enter Room entry. |
Status | Description |
idle | Idle, not playing and not in a room. |
playing | Streaming playback in progress, audience not yet in the room (Enter Room entry shown). |
inRoom | In the room, audience can participate in live comments, likes, gifts, co-hosting, etc. |
coGuest | Co-hosting (requesting or already on mic). |
end | Live has ended or audience was removed; the component displays the live ended page. |
Feature | Description | Integration Guide |
Host Streaming | The complete workflow for a host to start a stream, including pre-stream setup and various in-stream interactions. | |
Live Stream List | Display the live stream list interface and features, including the live stream list and room information display. | |
Gift System | Support custom gift asset configuration, billing system integration, and gift-sending in PK scenarios. |
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários