setup static method

Future<HMSException?> setup({
  1. bool? autoEnterPip,
  2. List<int>? aspectRatio,
  3. ScaleType scaleType = ScaleType.SCALE_ASPECT_FILL,
  4. Color backgroundColor = Colors.black,
})

setup PIP is used to setup PIP in iOS devices. parameters:

autoEnterPip - Enable autoEnterPip will start pip mode automatically when app minimized. Default value is true

aspectRatio - Ratio for PIP window. List of int indicating ratio for PIP window as width,height. For example: 16, 9, 9, 16 ,1, 1. Default value is [16, 9]

scaleType - To set the video scaling. scaleType can be one of the following: SCALE_ASPECT_FIT, SCALE_ASPECT_FILL, SCALE_ASPECT_BALANCED. Default value is ScaleType.SCALE_ASPECT_FILL

backgroundColor - To set the background colour when video is off that colour will be visible in background of PIP window. Default value is Colors.black.

Note: Use [changeVideoTrack] function to change track in PIP window. Default track is local peer video track if available.

setup PIP function can be called like - onJoin, or on click of a button, or when a Screenshare starts, etc

Refer PIP mode guide here

Implementation

static Future<HMSException?> setup(
    {bool? autoEnterPip,
    List<int>? aspectRatio,
    ScaleType scaleType = ScaleType.SCALE_ASPECT_FILL,
    Color backgroundColor = Colors.black}) async {
  var result =
      await PlatformService.invokeMethod(PlatformMethod.setupPIP, arguments: {
    "auto_enter_pip": autoEnterPip ?? true,
    "ratio": (aspectRatio != null && aspectRatio.length == 2)
        ? aspectRatio
        : [16, 9],
    "scale_type": scaleType.value,
    "color": [
      backgroundColor.red,
      backgroundColor.green,
      backgroundColor.blue
    ]
  });
  if (result != null) {
    return HMSException.fromMap(result["error"]);
  }
  _isPIPSetupDone = true;
  return null;
}