DetectRTC icon indicating copy to clipboard operation
DetectRTC copied to clipboard

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

Open hazratgs opened this issue 6 years ago • 4 comments

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

hazratgs avatar Oct 20 '19 11:10 hazratgs

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.

muaz-khan avatar Oct 20 '19 11:10 muaz-khan

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

hazratgs avatar Oct 20 '19 13:10 hazratgs

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

:(

Flyer3d avatar Nov 07 '19 07:11 Flyer3d

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 , 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.

industrialdeveloper avatar May 17 '22 10:05 industrialdeveloper