tencent cloud

Feedback

LiveKit API

Last updated: 2024-12-17 11:49:54

    API Introduction

    The TUILiveKit API is a UI interface for live components. Using the TUILiveKit API, you can quickly implement a live scene through a simple interface. For more detailed access steps, see: Quick Access to TUILiveKit.

    API Overview

    <LiveMainView />: The component body of TUILiveKit UI.
    liveRoom:dependencies LiveMainView provided API.
    API
    Description
    Access the roomEngine instance. If roomEngine does not exist, it will return null.
    on
    Listen to specified types of apid Integration with TUIRoomKit.
    Event. When the event occurs, the callback function will be called.
    off
    Cancel listening for events of a specified type.
    login
    Log in to the live system.
    logout
    Log out of the live system.
    start
    Start a new live.
    join
    Join an existing live.
    leave
    Leave the current live.
    dismiss
    Dismiss the current live.
    Set your user information.
    Set the interface language.
    setTheme
    Set the interface topic.

    liveRoom API Details

    liveRoom provides a range of methods for managing and controlling live features. By implementing this interface, developers can easily integrate live streaming functionality into their applications.

    getRoomEngine

    Access the roomEngine instance. If roomEngine does not exist, it will return null.
    import { liveRoom, TUIRoomEngine } from '@tencentcloud/livekit-web-vue3';
    TUIRoomEngine.once('ready', () => {
    const roomEngine = liveRoom.getRoomEngine();
    });
    Returns:TUIRoomEngine | null

    on

    Listen for a specified type of event. When the event occurs, the callback function will be called.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    eventType
    RoomEvent
    -
    Event Type to Listen For
    callback
    () => void
    -
    Callback Function Called When the Event Occurs
    import { liveRoom, RoomEvent } from '@tencentcloud/livekit-web-vue3';
    liveRoom.on(RoomEvent.RoomStart, () => {
    console.log('[liveRoom] The live has already started.')
    });
    liveRoom.on(RoomEvent.ROOM_DISMISS, () => {
    console.log('[liveRoom] The live has been dismissed')
    });
    Returns:void

    off

    Cancel listening for events of a specified type.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    eventType
    RoomEvent
    -
    The type of event to cancel listening for
    callback
    () => void
    -
    The callback function added previously
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.off('event', callback);
    Returns:void

    login

    Log in to the live system.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    params
    {sdkAppId: number; userId: string; userSig: string; tim?: ChatSDK}
    -
    Log in to the parameter object.
    sdkAppId
    number
    -
    In the Real-time Audio and Video Console click Application Management > create an application. After creating a new application, you can access the sdkAppId information in Application Information.
    userId
    string
    -
    It's advised to limit the User ID length to 32 bytes, allowing only uppercase and lowercase letters (a-zA-Z), digits (0-9), underscores, and hyphens.
    userSig
    string
    -
    userSig Signature
    For the method of calculating userSig, please refer to UserSig Related.
    tim
    ChatSDK (Optional)
    -
    If you want to leverage more capabilities of the Instant Messaging SDK while integrating roomEngine, you can pass the created tim instance into TUIRoomEngine. For how to create a tim instance, please refer to TIM.create.
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.login({
    sdkAppId: 123456,
    userId: 'testUser',
    userSig: 'testSig'
    });
    Returns:Promise<void>

    logout

    Log out of the live system.
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.logout();
    Returns:Promise<void>

    start

    Start a new live.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    roomId
    string
    -
    living Room ID
    params
    -
    Parameters for starting the living
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.start('123456', {
    roomName: 'TestRoom',
    isOpenCamera: false,
    isOpenMicrophone: false,
    });
    Returns:Promise<void>

    join

    Join an existing live.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    roomId
    string
    -
    living Room ID
    params
    -
    Parameters for joining the
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.join('123456', {
    isOpenCamera: false,
    isOpenMicrophone: false,
    });
    Returns:Promise<void>

    leave

    Leave the current live.
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.leave();
    Returns:Promise<void>

    dismiss

    Dismiss the current live.
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.dismiss();
    Returns:Promise<void>

    setSelfInfo

    Set your user information.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    options
    {userName: string; avatarUrl: string}
    -
    User information object
    userName
    string(Optional)
    -
    User's nickname
    avatarUrl
    string(Optional)
    -
    User profile photo
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.setSelfInfo({
    userName: 'test-name',
    avatarUlr: 'https://avatar.png'
    });
    Returns:Promise<void>

    setLanguage

    Set the interface language.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    language
    'zh-CN' | 'en-US'
    -
    Language
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.setLanguage('en-US');
    Returns:void

    setTheme

    Set the interface topic.
    The parameters are described as follows:
    Parameter
    Type
    Default Value
    Meaning
    theme
    'LIGHT' | 'DARK'
    -
    Topic Type
    import { liveRoom } from '@tencentcloud/livekit-web-vue3';
    liveRoom.setTheme('DARK');
    Returns:void

    Type Definition

    RoomEvent(enumeration)

    Parameter
    Type
    Description
    ROOM_START
    string
    Creating a live room
    ROOM_JOIN
    string
    Joining a live room
    ROOM_LEAVE
    string
    Leave live room
    ROOM_DISMISS
    string
    Live room Dismissed
    KICKED_OFFLINE
    string
    User kicked offline
    KICKED_OUT
    string
    Participant removed from living
    USER_LOGOUT
    string
    User logged out
    ROOM_ERROR
    string
    Live room error
    ROOM_NEED_PASSWORD
    string
    Live room password

    FeatureButton(enumeration)

    Parameter
    Type
    Description
    SwitchTheme
    string
    Switch Topic Feature Button
    SwitchLanguage
    string
    Switch Language Feature Button

    StartParams

    Parameter
    Type
    Description
    Default Value
    roomName
    string (Optional)
    Room Name
    -
    isOpenCamera
    boolean (optional)
    Whether to enable the camera
    false
    isOpenMicrophone
    boolean (optional)
    Whether to enable the microphone
    false
    defaultCameraId
    string (Optional)
    Default Camera ID
    -
    defaultMicrophoneId
    string (Optional)
    Default Microphone ID
    -
    defaultSpeakerId
    string (Optional)
    Default Speaker ID
    -

    JoinParams

    Parameter
    Type
    Description
    Default Value
    isOpenCamera
    boolean (optional)
    Whether to enable the camera
    false
    isOpenMicrophone
    boolean (optional)
    Whether to enable the microphone
    false
    defaultCameraId
    string (Optional)
    Default Camera ID
    -
    defaultMicrophoneId
    string (Optional)
    Default Microphone ID
    -
    defaultSpeakerId
    string (Optional)
    Default Speaker ID
    -
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support