changeText static method

Future<HMSException?> changeText({
  1. required String text,
  2. List<int>? aspectRatio,
  3. Color backgroundColor = Colors.black,
})

changeText is used to change the Text of PIP window.

It will remove the video track & only show the Text label

Parameters:

text - Text you want to show in PIP window. It will replace HMSVideoTrack if it playing in PIP window.

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: [setupPIP] is required to call before calling [changeTextPIP].

Refer PIP mode guide here

Implementation

static Future<HMSException?> changeText(
    {required String text,
    List<int>? aspectRatio,
    Color backgroundColor = Colors.black}) async {
  if (_isPIPSetupDone) {
    var result = await PlatformService.invokeMethod(
        PlatformMethod.changeTextPIP,
        arguments: {
          "text": text,
          "ratio": (aspectRatio != null && aspectRatio.length == 2)
              ? aspectRatio
              : [16, 9],
          "color": [
            backgroundColor.red,
            backgroundColor.green,
            backgroundColor.blue
          ]
        });
    if (result != null) {
      return HMSException.fromMap(result["error"]);
    }
  } else if (!_isPIPSetupDone) {
    return HMSException(
        message:
            "[setupPIP] is required to call before calling [changeTrackPIP]",
        description:
            "[setupPIP] is required to call before calling [changeTrackPIP]",
        action: "",
        isTerminal: false);
  }
  return null;
}