changeVideoTrack static method
changeVideoTrack is used to change the track of PIP window.
Parameters:
track - HMSVideoTrack need to be passed for changing PIP window track.
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]
.
alternativeText - Alternative text is a textual substitute if HMSVideoTrack is muted.This is the text which you wish to display when video for peer is OFF while in PIP
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 [changeTrackPIP].
Refer PIP mode guide here
Implementation
static Future<HMSException?> changeVideoTrack(
{required HMSVideoTrack track,
List<int>? aspectRatio,
required String alternativeText,
ScaleType scaleType = ScaleType.SCALE_ASPECT_FILL,
Color backgroundColor = Colors.black}) async {
if (_isPIPSetupDone) {
var result = await PlatformService.invokeMethod(
PlatformMethod.changeTrackPIP,
arguments: {
"track_id": track.trackId,
"ratio": (aspectRatio != null && aspectRatio.length == 2)
? aspectRatio
: [16, 9],
"alternative_text": alternativeText,
"scale_type": scaleType.value,
"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;
}