initialize method
Initialize the native virtual background system
Creates a native video source that can receive processed frames.
Implementation
Future<bool> initialize({
required int width,
required int height,
required int fps,
}) async {
if (!isSupported) {
debugPrint('VirtualBackgroundChannel: Not supported on this platform');
return false;
}
try {
final result = await _channel.invokeMethod<Map<dynamic, dynamic>>(
'initialize',
{
'width': width,
'height': height,
'fps': fps,
},
);
if (result != null && result['success'] == true) {
_virtualTrackId = result['trackId'] as String?;
debugPrint(
'VirtualBackgroundChannel: Initialized with track $_virtualTrackId');
return true;
}
return false;
} on PlatformException catch (e) {
debugPrint(
'VirtualBackgroundChannel: Failed to initialize: ${e.message}');
return false;
} on MissingPluginException {
debugPrint('VirtualBackgroundChannel: Native plugin not available');
return false;
}
}