createSubCloud method

Future<TRTCCloud> createSubCloud()

Create a child TRTC instance (for concurrent viewing in multiple rooms)

By calling this interface, you can create multiple TRTCCloud instances so that you can enter multiple different rooms to watch audio and video streams at the same time.

Sample code

cloud = (await TRTCCloud.sharedInstance())!;
//Create child instance
subCloud = await cloud!.createSubCloud();
//Destroy child instance
cluod.destroySubCloud(subCloud);

Notice

  • Currently child instances cannot support custom rendering.
  • The same user can use the same userId to enter multiple rooms with different roomIds.
  • You can set TRTCCloudListener for different instances to obtain respective event notifications.
  • The same user can push streams in multiple TRTCCloud instances, and can also call local audio and video-related interfaces in sub-instances.

Return value: TRTC instance

Not supported on:

  • web
  • MacOS
  • Windows

Implementation

Future<TRTCCloud> createSubCloud() async {
  TRTCCloud cloud = new TRTCCloud();
  MethodChannel channel = MethodChannel("trtcCloudChannel_${cloud.hashCode}");
  await _cloudChannel!.invokeMethod("createSubCloud", {
    "channelName" : channel.name,
  });
  cloud._cloudChannel = channel;
  return cloud;
}