startPublishingStream method

Future<void> startPublishingStream(
  1. String streamID,
  2. {ZegoPublisherConfig? config,
  3. 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:

  1. 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.
  2. Other users in the same room can get the streamID by monitoring the onRoomStreamUpdate event callback after the local user publishing stream successfully.
  3. 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.
  4. 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:
    1. Stream ID is defined by you.
    2. 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.
    3. 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);
}