Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission condition is false in flutter web #430

Open
Zeinab-Kouhkan opened this issue Nov 4, 2024 · 2 comments
Open

Permission condition is false in flutter web #430

Zeinab-Kouhkan opened this issue Nov 4, 2024 · 2 comments

Comments

@Zeinab-Kouhkan
Copy link

Zeinab-Kouhkan commented Nov 4, 2024

Package version

  • 5.2.0.

Environment

  • Browser [e.g. chrome, safari].

Describe the bug

The browser microphone permission is set to 'Allowed' after displaying the permission notification, and it’s confirmed by the user. However, when starting the recording, the hasPermission check returns false. I tested this on HTTPS with both the CanvasKit and HTML renderers, and it still returns false.

Add your record configuration

Future<void> startRecorder() async {
    try {
      if (await _audioRecorder.hasPermission()) {

        const encoder = AudioEncoder.wav;

        if (!await _isEncoderSupported(encoder)) {

          return;
        }

        final devs = await _audioRecorder.listInputDevices();
        debugPrint('Devices Has Microphone:  ${devs.toString()}');

        const config = RecordConfig(encoder: encoder, numChannels: 1);

        // Record to file
        await _recordFile(config);

        // Record to stream
        // await recordStream(_audioRecorder, config);

        _recordDuration.value = 0;

        _startTimer();
      }
    } catch (e) {
      debugPrint(e.toString());
    }
  }
  

Run flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.19045.5011], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
X Android SDK file not found: D:\sdk\android\platforms\android-35\android.jar.
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.90.1)
[√] Connected device (6 available)
[√] Network resources

@llfbandit
Copy link
Owner

The description is unclear. hasPermission already prompts the user for permission.
So how did you allow it?

Maybe a lead, hasPermission on web platform is not tied to a specific device.
Did you rejected the permission before for another device?

Finally, hasPermission call can eventually be skipped on web platform, the permission prompt will be sent to the user if needed (so not rejected of course).

@Zeinab-Kouhkan
Copy link
Author

This condition is checked when the user first starts the recording, and an access notification is displayed. The user grants access, but the condition returns false when the recording is restarted.
According to your opinion on the web, should I ignore this condition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants