
npm install tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3 --save
pnpm add tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3
yarn add tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3
live-player.vue file in your project. Copy and paste the following code to add the viewer page.<template><UIKitProvider theme="dark"><div class="container"><!-- Live Core Area --><section class="live"><header class="header"><IconArrowStrokeBack class="back-btn" size="20" /><Avatar :src="currentLive?.liveOwner.avatarUrl" :size="32" class="avatar" /><span class="user-name">{{ currentLive?.liveOwner.userName || currentLive?.liveOwner.userId }}</span></header><LiveCoreView class="player" /></section><div class="sidebar"><!-- Online Audience List --><section class="audience"><header class="section-header"><h3> Online Audience <span>({{ audienceList.length }})</span></h3></header><LiveAudienceList class="list" /></section><!-- Message List & Input Box --><section class="barrage"><header class="section-header"><h3>Message List</h3></header><BarrageList class="list" /><BarrageInput class="input" height="48px" /></section></div></div></UIKitProvider></template><script setup lang="ts">import { onMounted } from 'vue';import { LiveAudienceList, BarrageList, BarrageInput, useLiveAudienceState, LiveCoreView, useLiveListState, Avatar, useLoginState } from 'tuikit-atomicx-vue3';import { UIKitProvider, IconArrowStrokeBack } from '@tencentcloud/uikit-base-component-vue3';const { audienceList } = useLiveAudienceState();const { currentLive, joinLive } = useLiveListState();const { login, setSelfInfo } = useLoginState();const liveId = 'live_xxxx' // Enter the ID of the live stream you want to watchasync function initLogin() {try {await login({sdkAppId: 0, // SDKAppID, refer to Step 1 for detailsuserId: '', // UserID, refer to Step 1 for detailsuserSig: '', // userSig, refer to Step 1 for details});} catch (error) {console.error('Login failed:', error);}}onMounted(async () => {await initLogin();await setSelfInfo({userName: 'Your Name/Nickname', // UsernameavatarUrl: '', // Avatar URL});await joinLive({ liveId });});</script><style>html,body,#app{height:100%;width:100%;margin:0;padding:0;overflow:hidden}:global(body){font-size:15px;line-height:1.6;text-rendering:optimizeLegibility;}:global(*),:global(*::before),:global(*::after){box-sizing:border-box;margin:0;}.container{display:grid;grid-template-columns:1fr 320px;height:100%;width:100%;gap:16px;padding:16px;background:var(--bg-color-default);box-sizing:border-box;overflow:hidden;}.live{display:flex;flex-direction:column;background:var(--bg-color-operate);border-radius:12px;overflow:hidden;box-shadow:0 2px 8px var(--shadow-color);}.header{display:flex;align-items:center;gap:12px;padding:16px;border-bottom:1px solid var(--stroke-color-primary);}.back-btn{cursor:pointer;color:var(--text-color-tertiary);transition:color 0.2s;}.back-btn:hover{color:var(--text-color-link-hover);}.avatar{border:1px solid var(--uikit-color-white-7);}.user-name{color:var(--text-color-primary);font-weight:500;}.player{flex:1;background:var(--uikit-color-black-1);min-height:0;}.sidebar{display:flex;flex-direction:column;gap:16px;height:100%;overflow:hidden;}.audience{display:flex;flex-direction:column;background:var(--bg-color-operate);border-radius:12px;overflow:hidden;box-shadow:0 2px 8px var(--shadow-color);flex:1;min-height:0;}.barrage{display:flex;flex-direction:column;background:var(--bg-color-operate);border-radius:12px;overflow:hidden;box-shadow:0 2px 8px var(--shadow-color);flex:1;min-height:0;}.section-header{padding:16px;border-bottom:1px solid var(--stroke-color-primary);background:var(--bg-color-operate);}.section-header h3{margin:0;font-size:16px;font-weight:600;color:var(--text-color-primary);}.section-header span{font-weight:400;color:var(--text-color-secondary);font-size:14px;}.list{flex:1;min-height:0;overflow-y:auto;}.input{border-top:1px solid var(--stroke-color-primary);flex-shrink:0;height:48px;}@media (max-width:1200px){.container{grid-template-columns:1fr;grid-template-rows:60% 20% 20%;gap:12px;}.sidebar{gap:12px;}.audience,.barrage{min-height:200px;}}@media (max-width:768px){.container{padding:8px;gap:8px;grid-template-rows:50% 25% 25%;}.header,.section-header{padding:12px;}.sidebar{gap:8px;}}</style>
Parameters | Type | Required | Description |
userName | String | Yes | User nickname, shown in the live room and chat area. |
avatarUrl | String | No | URL of the user's avatar image. |
http://localhost:5173/live-player; the port may vary based on your setup) to access the viewer page.npm run dev
liveId to join the live room and view the stream.// src/router/index.tsimport { createRouter, createWebHistory } from 'vue-router';const routes = [{path: '/live-player',component: () => import('../live-player.vue'),},// To add the Live Stream List feature, include the following route. Update the path as needed for your project.// {// path: '/live-list',// component: () => import('../live-list.vue'),// },];const router = createRouter({history: createWebHistory(),routes,});export default router;// src/main.tsimport { createApp } from 'vue';import App from './App.vue';import router from './router';const app = createApp(App);app.use(router);app.mount('#app');
UIKitProvider within App.vue.UIKitProvider Parameter | Options | Default Value |
theme | "light" | "dark" |
language | "zh-CN" | "en-US" |
<UIKitProvider theme="light"><router-view /></UIKitProvider><script setup lang="ts">import { UIKitProvider } from '@tencentcloud/uikit-base-component-vue3';
live-player.vue and update the UI as needed.
Category | Feature | Description |
Asset Management | Customize asset management area display | Adjust icon size, color, or replace icons. |
Live Tools | Customize live tool information display | Adjust icon size, color, or replace icons. |
Online Audience | Customize audience information display | Supports: - Show/hide audience level. - Customize audience info font and color. - Use your preferred icon style. |
Message List | Customize live comments area display | Supports: - Show/hide chat input area. - Customize chat bubble style, audience level, and more. |
onAutoplayFailed callback. Below is a Vue3 sample that listens for the event and displays a custom dialog:import TUIRoomEngine, { TUIRoomEvents } from '@tencentcloud/tuiroom-engine-js';import { useUIKit, TUIMessageBox } from '@tencentcloud/uikit-base-component-vue3';import { useRoomEngine } from 'tuikit-atomicx-vue3';const roomEngine = useRoomEngine();let isShowAutoPlayDialog = false;export default function useCustomizedAutoPlayDialog() {const { t } = useUIKit();TUIRoomEngine.once('ready', () => {roomEngine.instance?.on(TUIRoomEvents.onAutoPlayFailed, () => {if (!isShowAutoPlayDialog) {isShowAutoPlayDialog = true;TUIMessageBox.alert({title: t('RoomCommon.Attention'),content: t('RoomNotifications.AudioPlaybackFailed'),showClose: false,modal: false,confirmText: t('Confirm'),callback: () => {isShowAutoPlayDialog = false;},});}});});}export { useCustomizedAutoPlayDialog };
@tencentcloud/tuiroom-engine-js package.Feature | Description | Integration Guide |
Live Stream List | Displays the live stream list interface and features, including live stream list and room information display. | |
TUILiveKit Manager | Operations platform for live room management. |
피드백