startPreview method

Future<void> startPreview(
  1. {ZegoCanvas? canvas,
  2. ZegoPublishChannel? channel}
)

Starts/Updates the local video preview (for the specified channel).

Available since: 1.1.0 Description: The user can see his own local image by calling this function. Use cases: It can be used for local preview in real-time connecting wheat, live broadcast and other scenarios. When to call: After createEngine. Restrictions: None. Caution: 1. The preview function does not require you to log in to the room or publish the stream first. But after exiting the room, SDK internally actively stops previewing by default. 2. Local view and preview modes can be updated by calling this function again. The user can only preview on one view. If you call startPreview again to pass in a new view, the preview screen will only be displayed in the new view. 3. You can set the mirror mode of the preview by calling the setVideoMirrorMode function. The default preview setting is image mirrored. 4. When this function is called, the audio and video engine module inside SDK will start really, and it will start to try to collect audio and video. Note: This function is only available in ZegoExpressVideo SDK!

  • canvas The view used to display the preview image. If the view is set to null, no preview will be made.
  • channel Publish stream channel

Implementation

Future<void> startPreview(
    {ZegoCanvas? canvas, ZegoPublishChannel? channel}) async {
  return await ZegoExpressImpl.instance
      .startPreview(canvas: canvas, channel: channel);
}