hasMicAccess method

  1. @override
Future<bool> hasMicAccess()
override

Queries current window for microphone permission. Returns true if permission is granted, false otherwise. Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query

Implementation

@override
Future<bool> hasMicAccess() async {
  Logger.logLocalEvent("checkPermissionForMicrophone");
  try {
    final perm = await _webPermissionsDelegate?.query({"name": "microphone"});
    if (perm == null) {
      printDebug("Failed to query microphone permission");
      return false;
    }
    if (perm.state == "granted") {
      return true;
    } else if (perm.state == "prompt") {
      Logger.logLocalEvent("RequestMicrophoneAccess");
      return false;
    } else {
      Logger.logLocalEvent("Microphone permission denied", prefix: "");
      return false;
    }
  } catch (e) {
    printDebug("Failed to query microphone permission");
    printDebug(e);
    return false;
  }
}