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

Detection of missing microphone access permission #348

Open
mario-van-zadel opened this issue Jun 26, 2022 · 2 comments
Open

Detection of missing microphone access permission #348

mario-van-zadel opened this issue Jun 26, 2022 · 2 comments

Comments

@mario-van-zadel
Copy link

Feature Request

Motivation Behind Feature

When using the plugin for recording some audio, the user probably denied accessing the microphone (by using the operation system's permission system). Currently there seems to be no explicit way to detect his. onError doesn't inform the developer about the denied permission request.

Feature Description

When accessing the microphone, the user get's a permission request from by the OS. If the user denies the request, the onError observable should inform the user about the issue when trying to use the device's microphone.

Workaround

To detect issues with recording the audio, it's possible to check the media's status after e.g. 1 second.
If there are some issues with starting the recording, the status stays at MEDIA_NONE (instead of switching to MEDIA_RUNNING).

this.mediaObject.onStatusUpdate.subscribe(status => {
    this.mediaObjectStatus = status;
});

this.mediaObject.startRecord();

// Check the media's status after 1 second.
setTimeout(() => {
    if (this.mediaObjectStatus === this.media.MEDIA_NONE) {
        alert('Recording failed. Please check the permissions for accessing the microphone');
    }
}, 1000);
@sonicwong
Copy link

sonicwong commented Dec 2, 2022

@mario-van-zadel
setTimeout solution is not working, I need to use document.addEventListener('resume');

One more thing I found for android platform.
I am using cordova-diagnostic-plugin to check diagnostic.getExternalStorageAuthorizationStatus.

First time: return NOT_REQUESTED
Rejected 1 time: return DENIED_ONCE
Rejected 2 time: return NOT_REQUESTED (it should be DENIED_ALWAYS)
** And app will never popup ask for permission even close and restart app.

If accepted: return GRANTED

@PabbleDabble
Copy link

I'm having the same issue, but once permission is denied, the mediaObject does not do anything, I'm not able to get any subscriptions to fire (which may be intended?)
I've tried

  • onStatusUpdate
  • successCallback
  • errorCallback
  • onSuccess
  • onError

The last two do work when permissions are granted. I was thinking about using getCurrentAmplitude (which resolves 0 when permissions not granted during record/play) to check if anything was happening, but not sure I like that or not.

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

3 participants