startPublishingStream method
- String streamID,
- {ZegoPublisherConfig? config,
- ZegoPublishChannel? channel}
Starts publishing a stream. Support multi-room mode.
Available since: 1.1.0
Description: Users push their local audio and video streams to the ZEGO RTC server or CDN, and other users in the same room can pull the audio and video streams to watch through the streamID
or CDN pull stream address.
Use cases: It can be used to publish streams in real-time connecting wheat, live broadcast and other scenarios.
When to call: After loginRoom
.
Restrictions: None.
Caution:
- Before start to publish the stream, the user can choose to call setVideoConfig to set the relevant video parameters, and call startPreview to preview the video.
- Other users in the same room can get the streamID by monitoring the onRoomStreamUpdate event callback after the local user publishing stream successfully.
- In the case of poor network quality, user publish may be interrupted, and the SDK will attempt to reconnect. You can learn about the current state and error information of the stream published by monitoring the onPublisherStateUpdate event.
- To call
SetRoomMode
function to select multiple rooms, the room ID must be specified explicitly.
streamID
Stream ID, a string of up to 256 characters. Caution:- Stream ID is defined by you.
- needs to be globally unique within the entire AppID. If in the same AppID, different users publish each stream and the stream ID is the same, which will cause the user to publish the stream failure. You cannot include URL keywords, otherwise publishing stream and playing stream will fails.
- Only support numbers, English characters and '-', '_'.
config
Advanced publish configuration.channel
Publish stream channel.
Implementation
Future<void> startPublishingStream(String streamID,
{ZegoPublisherConfig? config, ZegoPublishChannel? channel}) async {
return await ZegoExpressImpl.instance
.startPublishingStream(streamID, config: config, channel: channel);
}