startPlayingStream method

Future<void> startPlayingStream(
  1. String streamID,
  2. {ZegoCanvas? canvas,
  3. ZegoPlayerConfig? config}
)

Starts playing a stream from ZEGO RTC server or from third-party CDN. Support multi-room mode.

Available since: 1.1.0 Description: Play audio and video streams from the ZEGO RTC server or CDN. Use cases: In real-time or live broadcast scenarios, developers can listen to the onRoomStreamUpdate event callback to obtain the new stream information in the room where they are located, and call this interface to pass in streamID for play streams. When to call: After loginRoom. Restrictions: None. Caution: 1. The developer can update the player canvas by calling this function again (the streamID must be the same). 2. After the first play stream failure due to network reasons or the play stream is interrupted, the default time for SDK reconnection is 20min. 3. In the case of poor network quality, user play may be interrupted, the SDK will try to reconnect, and the current play status and error information can be obtained by listening to the onPlayerStateUpdate event. please refer to https://docs.zegocloud.com/faq/reconnect. 4. Playing the stream ID that does not exist, the SDK continues to try to play after calling this function. After the stream ID is successfully published, the audio and video stream can be actually played. Note: This function is only available in ZegoExpressVideo SDK!

  • streamID Stream ID, a string of up to 256 characters. Caution: Only support numbers, English characters and '-', '_'.
  • canvas The view used to display the play audio and video stream's image. When the view is set to null, no video is displayed, only audio is played.
  • config Advanced player configuration Room roomID in ZegoPlayerConfig is the login roomID.

Implementation

Future<void> startPlayingStream(String streamID,
    {ZegoCanvas? canvas, ZegoPlayerConfig? config}) async {
  return await ZegoExpressImpl.instance
      .startPlayingStream(streamID, canvas: canvas, config: config);
}