LiveCoreView
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, supporting both code creation and XML loading methods. | |
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 | |
Set a view adapter for adding widgets to the broadcaster's video screen |
API Details
LiveCoreView
Create an instance of the LiveCoreView object. Supports both code creation and XML loading methods.
public LiveCoreView(Context context)
Parameters:
Parameters | Type | Meaning |
context | Context | Android context object |
Return value: LiveCoreView
startCamera
Start camera capture and display the captured video on the LiveCoreView view.
public void startCamera(boolean useFrontCamera, ActionCallback callback)
Parameters:
Parameters | Type | Meaning |
useFrontCamera | boolean | true: use front camera, false: use rear camera |
callback | ActionCallback | Callback of the operation |
Returned value: void
startMicrophone
Enable the local microphone.
void startMicrophone(ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Returned value: void
muteMicrophone
Pause publishing the local audio stream.
void muteMicrophone(boolean mute)
Parameters:
Parameter | Type | Meaning |
mute | boolean | true: Pause video stream publishing, false: Normal video stream publishing |
Returned value:void
stopCamera
Turns the local camera off.
void stopCamera()
Parameters:
Returned value: void
stopMicrophone
Turn off the local microphone.
void stopMicrophone()
Parameters:
Returned value: void
startLiveStream
Anchor creates a live streaming room and starts streaming.
void startLiveStream(RoomInfo roomInfo, GetRoomInfoCallback callback)
Parameters:
Parameter | Type | Meaning |
roomInfo | RoomInfo | Create live room information |
callback | ActionCallback | Callback of the operation |
Returned value: void
stopLiveStream
Anchor stops streaming and destroys the live room.
void stopLiveStream(ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Returned value: void
joinLiveStream
Audience member joins an anchor's live streaming room.
void joinLiveStream(String roomId, GetRoomInfoCallback callback)
Parameters:
Parameter | Type | Meaning |
roomId | String | Live room ID |
callback | ActionCallback | Callback of the operation |
Returned value: void
leaveLiveStream
Audience member leaves an anchor's live streaming room.
void leaveLiveStream(ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
callback | ActionCallback | Callback of the operation |
Returned value: void
requestIntraRoomConnection
Audience member requests to connect with the anchor.
void requestIntraRoomConnection(String userId, int timeout, boolean openCamera, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
userId | String | User ID. If left blank, it represents the anchor's user ID. |
timeout | int | Request timeout duration, unit: seconds. |
openCamera | boolean | Whether to turn on the camera after a successful mic connection. true: video mic connect, false: voice mic connect. |
callback | ActionCallback | Callback of operations. |
Returned value: void
cancelIntraRoomConnection
Audience member cancels the request to connect with the anchor.
void cancelIntraRoomConnection(String userId, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
userId | String | User ID of the user who cancels the mic connection. If left blank, it represents the anchor's user ID. |
callback | ActionCallback | Callback of the operation |
Returned value: void
respondIntraRoomConnection
The anchor responds to the audience's request for connection.
void respondIntraRoomConnection(String userId, boolean isAccepted, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
userId | String | Responding user's User ID |
isAccepted | isAccepted | Whether to accept the mic connection request. true: accept the mic connection request, false: reject the mic connection request |
callback | ActionCallback | Callback of the operation |
Returned value: void
disconnectUser
The anchor disconnects the connected audience member.
void disconnectUser(String userId, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
userId | String | The anchor needs to disconnect the co-anchoring user's ID |
callback | ActionCallback | Callback of the operation |
Returned value: void
terminateIntraRoomConnection
The audience member stops the connection with the anchor themselves.
void terminateIntraRoomConnection()
Parameters: None
Returned value: void
requestCrossRoomConnection
Anchor requests to connect with another anchor in a different live room.
void requestCrossRoomConnection(String roomId, int timeout, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
roomId | String | Room ID of the cross-room connection request. |
timeout | int | Request timeout duration, unit: seconds. |
callback | ActionCallback | Callback of operations. |
Returned value: void
cancelCrossRoomConnection
Anchor cancels the request to connect with another anchor in a different live room.
void cancelCrossRoomConnection(String roomId, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
roomId | String | Room ID to cancel the connection |
callback | ActionCallback | Callback of the operation |
Returned value: void
respondToCrossRoomConnection
The anchor responds to the connection request.
void respondToCrossRoomConnection(String roomId, boolean isAccepted, ActionCallback callback)
Parameters:
Parameter | Type | Meaning |
roomId | String | Room ID for the response to the connection |
isAccepted | boolean | Whether to agree to the connection, true: agree to the connection, false: reject the connection |
callback | ActionCallback | Callback of the operation |
Returned value: void
terminateCrossRoomConnection
The anchor disconnects the connection.
void terminateCrossRoomConnection()
Parameters: None
Returned value: void
registerConnectionObserver
Register a connection event callback.
void registerConnectionObserver(ConnectionObserver observer)
Parameters:
Parameter | Type | Meaning |
observer | Callback object for connection events |
Returned value: void
unregisterConnectionObserver
Unregister a connection event callback.
void unregisterConnectionObserver(ConnectionObserver observer)
Parameters:
Parameter | Type | Meaning |
observer | Callback object for connection events |
Returned value: void
setLayoutMode
Set the layout mode of the connected broadcaster's video screen.
void setLayoutMode(LayoutMode layoutModel, String layoutJson)
Parameters:
Parameter | Type | Meaning |
layoutModel | Layout mode during connection, supporting grid layout, floating window layout, and custom layout. | |
layoutJson | String | Layout JSON string |
Returned value: void
setVideoViewAdapter
Set a view adapter for adding widgets to the broadcaster's video screen.
void setVideoViewAdapter(LiveCoreViewDefine.VideoViewAdapter viewAdapter)
Parameters:
Parameter | Type | Meaning |
viewAdapter | View adapter for adding widgets to the broadcaster's video screen |
Returned value: void
- API Overview
- API Overview
- API Details
- stopMicrophone
- startLiveStream
- stopLiveStream
- joinLiveStream
- leaveLiveStream
- requestIntraRoomConnection
- cancelIntraRoomConnection
- respondIntraRoomConnection
- disconnectUser
- terminateIntraRoomConnection
- requestCrossRoomConnection
- cancelCrossRoomConnection
- respondToCrossRoomConnection
- terminateCrossRoomConnection
- registerConnectionObserver
- unregisterConnectionObserver
- setLayoutMode
- setVideoViewAdapter