enable method
Enable virtual background for a video track.
trackId - The ID of the local video track to process
backgroundImage - The background image as PNG/JPEG bytes
confidence - Segmentation confidence threshold (0.0-1.0, default 0.7)
Returns true if virtual background was enabled successfully.
Implementation
Future<bool> enable({
required String trackId,
required Uint8List backgroundImage,
double confidence = 0.7,
}) async {
if (!isSupported) {
return false;
}
if (!_isInitialized) {
return false;
}
try {
final result = await _channel.invokeMethod<Map>('enable', {
'trackId': trackId,
'imageBytes': backgroundImage,
'confidence': confidence,
});
final success = result?['success'] as bool? ?? false;
if (success) {
_isEnabled = true;
}
return success;
} catch (e) {
return false;
}
}