previewForRole method

Future previewForRole({
  1. required String role,
})

Preview for a specific Role before changing it.

By previewing before doing a Role Change, users can see their expected Audio & Video tracks which will be visible to other Peers in Room post changing the Role. Parameters:

role - The new role into which the Peer is going to be changed into.

This returns an object of Future

Refer previewForRole guide here

Implementation

Future<dynamic> previewForRole({required String role}) async {
  var arguments = {
    "role_name": role,
  };
  var result = await PlatformService.invokeMethod(
      PlatformMethod.previewForRole,
      arguments: arguments);

  if (result["success"]) {
    List<HMSTrack> tracks = [];
    (result["data"] as List).forEach((track) {
      tracks.add(track['instance_of']
          ? HMSVideoTrack.fromMap(map: track, isLocal: true)
          : HMSAudioTrack.fromMap(map: track, isLocal: true));
    });

    return tracks;
  } else {
    return HMSException.fromMap(result["data"]["error"]);
  }
}