tencent cloud

Feedback

LiveCoreView

Last updated: 2024-12-27 16:26:44

    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 the anchor ID is passed in, it means the audience is requesting to connect with the anchor (if an empty string is passed in, it means the anchor UserID by default). If it is another user's UserID, it means the anchor is inviting the audience 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 connection, if the anchor ID is passed in, it means the audience is canceling the request to connect with the anchor (if an empty string is passed in, it means the anchor UserID by default). If it is another user's UserID, it means the anchor is canceling the invitation to connect with the corresponding userId.
    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 the anchor's User ID is passed in, it means the audience is responding to the anchor's invitation to connect (if an empty string is passed in, it means the anchor UserID by default).
    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

    Type Definition

    Type
    Description
    Set callback events for core control connections.
    Layout mode during connection, supporting grid layout, floating window layout, and custom layout.
    Connection view adapter interface, which allows you to add widgets to each audio and video stream view by implementing this interface.

    ConnectionObserver

    Type
    Description
    Callback for changes in the list of connected users.
    Callback for receiving a connection request.
    Callback for receiving a request to cancel the connection.
    Callback for connection request approval.
    Callback for connection request rejection.
    Callback for connection request timeout.
    Callback for the host disconnecting the connection with this viewer.
    Callback for the viewer actively disconnecting.
    Callback for changes in the cross-room connection room list.
    Callback for receiving a cross-room connection request.
    Callback for receiving a request to cancel the cross-room connection.
    Received callback for consent to cross-room connection
    Received callback for cross-room connection rejection
    Received callback for cross-room connection timeout.
    Received callback for cross-room disconnection.
    Received callback for room termination.

    LayoutMode

    Layout mode during connection
    Type
    Description
    gridLayout
    Grid Layout.
    floatLayout
    Floating Window Layout.
    freeLayout
    Custom Layout.

    VideoViewDelegate

    Connection view delegate interface, which allows you to add widgets to each audio and video stream view by implementing this interface.
    API
    Description
    Callback when creating a connected audience view. The View created through this API will be displayed on the connected audience's view.
    Callback when updating the connected audience view.
    Callback when creating a connected host view, the View created through this API will be displayed on the connected host's view.
    Callback when updating the connected host view.

    Callback Event Details

    onConnectedUsersUpdated

    Callback for changes in the list of connected users.
    func onConnectedUsersUpdated(userList: [TUIUserInfo], joinList: [TUIUserInfo], leaveList: [TUIUserInfo])
    Parameters:
    Parameter
    Type
    Description
    userList
    List of connected users
    joinList
    Newly connected users
    leaveList
    Users who have left the connection

    onUserConnectionRequest

    Callback for receiving a connection request.
    func onUserConnectionRequest(inviterUser: TUIUserInfo)
    Parameters:
    Parameter
    Type
    Description
    inviterUser
    Information of the user applying for connection

    onUserConnectionCancelled

    Callback for receiving a request to cancel the connection.
    func onUserConnectionCancelled(inviterUser: TUIUserInfo)
    Parameters:
    Parameter
    Type
    Description
    inviterUser
    Information of the user canceling the connection

    onUserConnectionAccepted

    Callback for connection request approval.
    func onUserConnectionAccepted(userInfo: TUIUserInfo)
    Parameters:
    Parameter
    Type
    Description
    userInfo
    Information of users who agreed to the connection

    onUserConnectionRejected

    Callback for connection request rejection.
    func onUserConnectionRejected(userInfo: TUIUserInfo)
    Parameters:
    Parameter
    Type
    Description
    userInfo
    Information of users who rejected the connection

    onUserConnectionTimeout

    Callback for connection request timeout.
    func onUserConnectionTimeout(userInfo: TUIUserInfo)
    Parameters:
    Parameter
    Type
    Description
    userInfo
    Information of users whose connection request timed out

    onUserConnectionTerminated

    The callback for the anchor disconnecting the mic connect with this audience.
    func onUserConnectionTerminated()

    onUserConnectionExited

    The callback for the user disconnecting from the seat.
    func onUserConnectionExited(userInfo: TUIUserInfo)
    Parameters:
    Parameter
    Type
    Description
    userInfo
    Information of users disconnected from the seat

    onConnectedRoomsUpdated

    The callback for changes in the room list of connections.
    func onConnectedRoomsUpdated(hostUserList: [TUIConnectionUser])
    Parameters:
    Parameter
    Type
    Description
    hostUserList
    List of room owners of the connected room

    onCrossRoomConnectionRequest

    The callback for receiving a cross-room connection request.
    func onCrossRoomConnectionRequest(hostUser: TUIConnectionUser)
    Parameters:
    Parameter
    Type
    Description
    hostUser
    Information on the live streaming room owner requesting a connection

    onCrossRoomConnectionCancelled

    Callback for receiving a cancellation request for a cross-room connection.
    func onCrossRoomConnectionCancelled(hostUser: TUIConnectionUser)
    Parameters:
    Parameter
    Type
    Description
    hostUser
    Cancel the information of the live streaming room owner requesting a connection

    onCrossRoomConnectionAccepted

    Callback for receiving an approval for a cross-room connection request.
    func onCrossRoomConnectionAccepted(hostUser: TUIConnectionUser)
    Parameters:
    Parameter
    Type
    Description
    hostUser
    Information on the live streaming room owner agreeing to the connection

    onCrossRoomConnectionRejected

    Callback for receiving a rejection of a cross-room connection request.
    func onCrossRoomConnectionRejected(hostUser: TUIConnectionUser)
    Parameters:
    Parameter
    Type
    Description
    hostUser
    Information on the live streaming room owner rejecting the connection

    onCrossRoomConnectionTimeout

    Callback for a timeout in receiving a room connection request.
    func onCrossRoomConnectionTimeout(inviter: TUIConnectionUser, invitee: TUIConnectionUser)
    Parameters:
    Parameter
    Type
    Description
    inviter
    Information on the live streaming room owner requesting a connection
    invitee
    Information on the live streaming room owner being invited to connect

    onCrossRoomConnectionExited

    Callback for changes in the connected users list.
    func onCrossRoomConnectionExited(hostUser: TUIConnectionUser)
    Parameters:
    Parameter
    Type
    Description
    hostUser
    Information of the live streaming room exiting the connection

    onRoomDismissed

    Callback of live streaming room termination.
    func onRoomDismissed(roomId: String)
    Parameters:
    Parameter
    Type
    Description
    roomId
    String
    Room ID

    createCoGuestView

    Create a pendant view for audience connection, which will be added to the user's video stream.
    func createCoGuestView(userInfo: TUIUserInfo) -> UIView?
    Parameters:
    Parameter
    Type
    Description
    userInfo
    User information of users connected to the microphone
    Return value: UIView?

    updateCoGuestView

    Callback for updating the pendant view. In general, you don't need to concern yourself with this callback. You can update your set pendant view based on the state of your pendant data unless your pendant depends on changes in userInfo.
    func updateCoGuestView(userInfo: TUIUserInfo, coGuestView: UIView)
    Parameters:
    Parameter
    Type
    Description
    userInfo
    User information of users connected to the microphone
    coGuestView
    UIView
    The pendant view you created using the createCoGuestView API

    createCoHostView

    Create a pendant view for the host's connection, which will be added to the connected host's video stream.
    func createCoHostView(connectionUser: TUIConnectionUser) -> UIView?
    Parameters:
    Parameter
    Type
    Description
    connectionUser
    User information of the connected host
    Return value: UIView?

    updateCoHostView

    Callback for updating the pendant view. In general, you don't need to concern yourself with this callback. You can update your set pendant view based on the state of your pendant data unless your pendant depends on changes in connectionUser.
    func updateCoHostView(connectionUser: TUIConnectionUser, coHostView: UIView)
    Parameters:
    Parameter
    Type
    Description
    connectionUser
    Information of the connected host
    coHostView
    UIView
    The pendant view you created using the createCoHostView API
    
    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