LiveStreamCore
module's LiveCoreView
to start a live broadcast. Only after the broadcast starts can other viewers enter the live room to watch the host's live stream.LiveStreamCore
, you need to integrate and log in to LiveStreamCore to ensure the subsequent features work properly.LiveStreamCore
module, then create a LiveCoreView
view object and add it to your view.import RTCRoomEngineimport LiveStreamCoreclass BroadcastController: UIViewController {private let liveCoreView: LiveCoreView = {let view = LiveCoreView()return view}()override func viewDidLoad() {super.viewDidLoad()// Add liveCoreView to the view and set layout constraints}}
import com.trtc.uikit.livekit.livestreamcore.LiveCoreView;public class LiveActivity extends AppCompatActivity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);LiveCoreView liveCoreView = new LiveCoreView(this);addContentView(liveCoreView,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));}}
startLiveStream
API, you need to fill in the key parameters TUIRoomInfo
. The detailed introduction is as follows:TUIRoomInfo
consists of many fields, but usually, you only need to focus on filling in the following fields:Parameter Name | Field Description | Additional Notes | Data Type | Example |
roomId | Room ID | Only letters (a-z, A-Z), digits (0-9), underscores, and hyphens are allowed. | New Character String | "room_100001" |
name | Room Name | Room name of string type. | New Character String | "denny`s room" |
seatMode | Microphone Mode | This field is effective only when microphone control is enabled. It is divided into "freeToTake" and "applyToTake" modes. In freeToTake mode, audience members can take the microphone freely without applying. In applyToTake mode, audience members need the room owner's approval to take the microphone. | Enumeration Value | TUISeatMode.applyToTake |
maxSeatCount | Maximum Number of Microphones | The maximum number of mic positions of numeric type, referring to the maximum number of people on mic simultaneously, maxSeatCount. The maximum number of seats is consistent with the maximum number of participants in the package you purchased. | Digits | 10 |
isSeatEnabled | Whether to enable microphone position control | Boolean type mic control enable flag. | Boolean value | true |
roomType | Room type | There are two types of rooms: "conference" and "live". For video live streaming, use live. | Enumeration Value | TUIRoomType.live |
TUIRoomInfo
in step 2, you can call the startLiveStream
API function to start the live stream.startCamera
and startMicrophone
APIs to turn on the local camera and microphone, ensuring that the audience can see your video and hear your voice.// Assemble TRTC room entry parameters. Replace the field values in `TRTCParams` with your own parameter valueslet roomInfo = TUIRoomInfo()roomInfo.roomId = "voice_100001" // Please replace it with your own room ID.roomInfo.name = "denny`s room" // Please replace it with your own room name.roomInfo.maxSeatCount = 10 // Please replace it with the maximum number of seats in the Live package you purchased.roomInfo.isSeatEnabled = true // If you do not need seat control, you can set isSeatEnabled to falseroomInfo.roomType = .live // Ensure the room type is live.roomInfo.seatMode = .applyToTake // The usual mode for video live streaming is applyToTake.self.liveCoreView.startLiveStream(roomInfo: roomInfo) { [weak self] roomInfo in// Going live successfullyguard let self = self else { return }// Turn the local camera onself.liveCoreView.startCamera(useFrontCamera: true) { // This selects the front camera. You can also pass in false to select the rear camera.// Successfully turned the local camera on} onError: { code, message in// Failed to turn the local camera on}// Turn the local mic onself.liveCoreView.startMicrophone {// Successfully turned the local mic on} onError: { code, message in// Failed to turn the local mic on}} onError: { code, message in// Failed to go live}
TUIRoomDefine.RoomInfo roomInfo = new TUIRoomDefine.RoomInfo();roomInfo.roomId = "voice_100001"; // Please replace it with your own room IDroomInfo.name = "denny's room"; // Please replace it with your own room nameroomInfo.maxSeatCount = 10; // Please replace it with the maximum number of seats in the Live package you purchasedroomInfo.isSeatEnabled = true; // If you do not need seat control, you can set isSeatEnabled to falseroomInfo.roomType = TUIRoomDefine.RoomType.LIVE; // Ensure the room type is live.roomInfo.seatMode = TUIRoomDefine.SeatMode.APPLY_TO_TAKE; // The usual mode for video live streaming is applyToTake.liveCoreView.startLiveStream(roomInfo, new TUIRoomDefine.GetRoomInfoCallback() {@Overridepublic void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {// Going live successfullyliveCoreView.startCamera(true, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully turned the local camera on}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to turn the local camera on}});liveCoreView.startMicrophone( new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successfully turned the local mic on}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to turn the local mic on}});}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to go live}});
Was this page helpful?