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

If you deny access to the micphone or camera, then DetectRTC returns true for the micphone and camera #82

Open
hazratgs opened this issue Oct 20, 2019 · 4 comments

Comments

@hazratgs
Copy link

Greetings friends, I noticed that in a particular case, DetectRTC does not work at all, for example

  1. We prohibit the site access to the camera, and allow the microphone
  2. DetectRTC will return the following:
    DetectRTC.isWebsiteHasMicrophonePermissions: true
    DetectRTC.isWebsiteHasWebcamPermissions: true

although isWebsiteHasWebcamPermissions should be false

@muaz-khan
Copy link
Owner

Did you try this?

navigator.mediaDevices.getUserMedia({
    audio: true,
    video: true
}).then(function() {
    DetectRTC.load(function() {
        alert('isWebsiteHasMicrophonePermissions: ' + DetectRTC.isWebsiteHasMicrophonePermissions);
    });
}).catch(function() {
    DetectRTC.load(function() {
        alert('isWebsiteHasMicrophonePermissions: ' + DetectRTC.isWebsiteHasMicrophonePermissions);
    });
});

i.e. execute DetectRTC.load inside getUserMedia error-success callbacks.

@hazratgs
Copy link
Author

hazratgs commented Oct 20, 2019

Did you try this?

navigator.mediaDevices.getUserMedia({
    audio: true,
    video: true
}).then(function() {
    DetectRTC.load(function() {
        alert('isWebsiteHasMicrophonePermissions: ' + DetectRTC.isWebsiteHasMicrophonePermissions);
    });
}).catch(function() {
    DetectRTC.load(function() {
        alert('isWebsiteHasMicrophonePermissions: ' + DetectRTC.isWebsiteHasMicrophonePermissions);
    });
});

i.e. execute DetectRTC.load inside getUserMedia error-success callbacks.

Thanks for the quick response
navigator.mediaDevices.getUserMedia method does not work in Safari 11 and below

and besides, there is a bug described above, it also does not work, for example:

navigator.mediaDevices.getUserMedia({ audio: true, video: true })
  .then(() => this.getStatusUserMedia())
  .catch((err) => {
      this.getStatusUserMedia()
      console.log('mediaDevices', err)
})

getStatusUserMedia = () => DetectRTC.load(() => {
    console.log('getStatusUserMedia ', {
      hasMicrophonePermissions: DetectRTC.isWebsiteHasMicrophonePermissions,
      hasWebcamPermissions: DetectRTC.isWebsiteHasWebcamPermissions,
    })
    this.setState({
      hasMicrophonePermissions: DetectRTC.isWebsiteHasMicrophonePermissions,
      hasWebcamPermissions: DetectRTC.isWebsiteHasWebcamPermissions,
    })
  })

if you enable the microfon and disable the camera in Safari settings (as well as in Chrome), the following occurs, I can’t determine in .catch what exactly the microfon or camera was blocked for me
image
image

the most amazing thing is that in this case, DetectRTC will return true for both the microfone and the camera, that is, it does not work (

image

@Flyer3d
Copy link

Flyer3d commented Nov 7, 2019

I have the same issue.
In the Chrome browser 78.0.3904.87 (Mac), I am denied access to the camera, but I get:

DetectRTC.isWebsiteHasMicrophonePermissions: true
DetectRTC.isWebsiteHasWebcamPermissions: true

:(

@industrialdeveloper
Copy link

industrialdeveloper commented May 17, 2022

I had the same issue. Even if I removed the Webcam and Microphone, I still received "true" for both.. (tested in Firefox and Chrome latest versions in different machines, results are same). (tested script is https://raw.githubusercontent.com/muaz-khan/DetectRTC/master/DetectRTC.js)

However, when I use the script directly provided in <script src="https://github.com/muaz-khan/DetectRTC/releases/download/1.4.1/DetectRTC.js"></script>, it works perfectly.

I did not understand what is the problem. Release works fine, but the same versioned DetectRTC.js scriptprovided in main repository do not work properly. I did not compare the scripts, but I believe that, there is a difference in these two scripts.

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

4 participants