requestPermissions method
Requests necessary permissions for system audio capture.
On macOS, this requests screen recording permission which is required to capture system audio.
Returns true if permissions are granted.
Throws an Exception if permissions are not granted.
Example:
try {
final hasPermission = await systemCapture.requestPermissions();
if (hasPermission) {
await systemCapture.startCapture();
}
} catch (e) {
print('Permission denied: $e');
}
Implementation
Future<bool> requestPermissions() async {
final hasPermission = await _channel.invokeMethod<bool>(
_SystemAudioMethod.requestPermissions.name,
);
if (hasPermission != true) {
throw Exception('Screen recording permission not granted');
}
return true;
}