muaz-khan / DetectRTC

DetectRTC is a tiny JavaScript library that can be used to detect WebRTC features e.g. system having speakers, microphone or webcam, screen capturing is supported, number of audio/video devices etc. https://www.webrtc-experiment.com/DetectRTC/
https://www.webrtc-experiment.com/DetectRTC/
MIT License
664 stars 163 forks source link

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

Open hazratgs opened 4 years ago

hazratgs commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 2 years ago

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.