tencent cloud

Feedback

LiveCoreView

Last updated: 2024-12-04 17:34:15

    API Overview

    LiveCoreView is a fundamental control developed for our video live streaming UIKit. This core control provides rich APIs such as preview before broadcasting, start video live streaming, stop video live streaming, live streaming room connection with audience, and cross-room connection with other anchors.

    API Overview

    API
    Description
    Create LiveCoreView object.
    Start camera capture and display the captured video on LiveCoreView.
    Turn on the local microphone
    Pause publishing local audio stream
    Turns the local camera off
    Turn off the local microphone
    Anchor creates a live streaming room and starts streaming
    Anchor stops streaming and destroys the live room
    Audience member joins an anchor's live streaming room
    Audience member leaves an anchor's live streaming room
    Audience member requests to connect with the anchor
    Audience member cancels the request to connect with the anchor
    Anchor responds to the audience member's request for connection
    Anchor disconnects the connected audience member
    Audience member stops the connection with the anchor themselves
    Anchor requests to connect with another anchor in a different live room
    Anchor cancels the request to connect with another anchor in a different live room
    Anchor responds to the connection request
    Anchor disconnects the connection
    Register a connection event callback
    Unregister a connection event callback
    Set the layout mode of the connected broadcaster's video screen
    delegate
    Set a view adapter for adding widgets to the broadcaster's video screen

    API Details

    LiveCoreView

    Create an instance of the LiveCoreView object.
    LiveCoreView()

    startCamera

    Start camera capture and display the captured video on the LiveCoreView view.
    func startCamera(useFrontCamera: Bool, onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    useFrontCamera
    Bool
    true: use front camera, false: use rear camera
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    startMicrophone

    Enable the local microphone.
    func startMicrophone(onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    muteMicrophone

    Pause publishing the local audio stream.
    func muteMicrophone(mute: Bool)
    Parameters:
    Parameters
    Type
    Meaning
    mute
    Bool
    true: Pause video stream publishing, false: Normal video stream publishing

    stopCamera

    Turns the local camera off.
    func stopCamera()

    stopMicrophone

    Turn off the local microphone.
    func stopMicrophone()

    startLiveStream

    Anchor creates a live streaming room and starts streaming.
    func startLiveStream(roomInfo: TUIRoomInfo,
    onSuccess: @escaping TUIRoomInfoBlock,
    onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    roomInfo
    TUIRoomInfo
    Create live room information
    onSuccess
    TUIRoomInfoBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    stopLiveStream

    Anchor stops streaming and destroys the live room.
    func stopLiveStream(onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    joinLiveStream

    Audience member joins an anchor's live streaming room.
    func joinLiveStream(roomId: String,
    onSuccess: @escaping TUIRoomInfoBlock,
    onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    roomId
    String
    Live room ID
    onSuccess
    TUIRoomInfoBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    leaveLiveStream

    Audience member leaves an anchor's live streaming room.
    func leaveLiveStream(onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    requestIntraRoomConnection

    Audience member requests to connect with the anchor.
    func requestIntraRoomConnection(userId: String, timeOut: Int, openCamera: Bool,
    onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    userId
    String
    User ID. If an empty string is passed, it means the audience requests to connect with the host. If not empty, it means the host invites the user with the corresponding userId to connect.
    timeout
    int
    Request timeout duration, unit: seconds.
    openCamera
    Bool
    Whether to turn on the camera after a successful mic connection. true: video connect, false: voice connect.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    cancelIntraRoomConnection

    Audience cancels the request to connect with the host.
    func cancelIntraRoomConnection(userId: String,
    onSuccess: @escaping TUISuccessBlock,
    onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    userId
    String
    User ID to cancel the mic connect. If an empty string is passed, it means the audience cancels the request to connect with the host. If not empty, it means the host cancels the invitation for the user with the corresponding userId to connect.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    respondIntraRoomConnection

    Anchor responds to the audience's request to connect.
    func respondIntraRoomConnection(userId: String, isAccepted: Bool,
    onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    userId
    String
    Audience user ID to respond to the host's invitation to connect. If an empty string is passed, it means the audience responds to the host's invitation to connect.
    isAccepted
    isAccepted
    Whether to accept the mic connect request. true: accept the mic connect request, false: reject the mic connect request.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    disconnectUser

    The anchor disconnects the audience.
    func disconnectUser(userId: String, onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    userId
    String
    The user ID that the anchor needs to disconnect.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    terminateIntraRoomConnection

    The audience stops the connection with the anchor.
    func terminateIntraRoomConnection()

    requestCrossRoomConnection

    The anchor requests to connect with another room's anchor.
    func requestCrossRoomConnection(roomId: String, timeOut: Int,
    onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    roomId
    String
    The Room ID for cross-room connection request.
    timeout
    int
    Request timeout duration, unit: seconds.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    cancelCrossRoomConnection

    Anchor cancels the request to connect with another host in a different room.
    func cancelCrossRoomConnection(roomId: String, onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    roomId
    String
    Room ID for canceling the connection.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    respondToCrossRoomConnection

    Anchor responds to the connection request.
    func respondToCrossRoomConnection(roomId: String, isAccepted: Bool,
    onSuccess: @escaping TUISuccessBlock, onError: @escaping TUIErrorBlock)
    Parameters:
    Parameters
    Type
    Meaning
    roomId
    String
    Room ID for responding to the connection request.
    isAccepted
    boolean
    Whether to accept the connection. true: accept the connection, false: reject the connection.
    onSuccess
    TUISuccessBlock
    The success callback
    onError
    TUIErrorBlock
    The failure callback

    terminateCrossRoomConnection

    The anchor disconnects the connection.
    func terminateCrossRoomConnection()

    registerConnectionObserver

    Register a connection event callback.
    func registerConnectionObserver(observer: ConnectionObserver)
    Parameters:
    Parameters
    Type
    Meaning
    observer
    Callback object for connection events.

    unregisterConnectionObserver

    Unregister a connection event callback.
    func unregisterConnectionObserver(observer: ConnectionObserver)
    Parameters:
    Parameters
    Type
    Meaning
    observer
    Callback object for connection events.

    setLayoutMode

    Set the layout mode for the connected host's video.
    func setLayoutMode(layoutMode: LayoutMode, layoutJson: String? = nil)
    Parameters:
    Parameters
    Type
    Meaning
    layoutModel
    Layout mode during connection, supporting grid layout, floating window layout, and custom layout.
    layoutJson
    String
    JSON string for the layout. For specific settings, refer to Setting Custom Layout.

    delegate

    Set the view delegate for adding widgets to the connected host's video.
    public weak var videoViewDelegate: VideoViewDelegate?
    Parameters:
    Parameters
    Type
    Meaning
    viewAdapter
    View Delegate for Adding Widgets to Live Stream Video
    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