Giter VIP home page Giter VIP logo

muaz-khan / detectrtc Goto Github PK

View Code? Open in Web Editor NEW
659.0 30.0 161.0 397 KB

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/

Home Page: https://www.webrtc-experiment.com/DetectRTC/

License: MIT License

JavaScript 74.50% HTML 25.50%
webrtc webrtc-demos webrtc-experiments

detectrtc's People

Contributors

abv avatar bbenezech avatar bennycode avatar brianpursley avatar ckaczor avatar davidmaarek avatar johnforte avatar lchoulette avatar matzko avatar modalityz avatar muaz-khan avatar nag5000 avatar piotrrussw avatar rodrigoscna avatar thadeu avatar vub avatar will093 avatar yeshiqing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

detectrtc's Issues

Angular 2+

Do you have the type script code for DetectRTC.

Mobile Detection

Right now the isMobileDevice script is a bit naive, but it gets the job done for 99% of devices. I propose we upgrade to:

var isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(navigator.userAgent)

(source: http://stackoverflow.com/a/25394023/696130)

or something more sophisticated taken from isMobile.js.

DetectRTC IE issues

Hello.

An error occurred when call function navigator.mediaDevices.enumerateDevices() for Internet Explorer 11 (and higher). This error occurred in this code part (DetectRTC.js):

if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
    // Firefox 38+ seems having support of enumerateDevices
    // Thanks @xdumaine/enumerateDevices
    navigator.enumerateDevices = function(callback) {
        navigator.mediaDevices.enumerateDevices().then(callback).catch(function() {
            callback([]);
        });
    };
}

Thank for your work.

Feature Request

Chrome , Firefox and Safari and other browser's version is latest or not..

For example ,

  1. DetectRTC.browser.isChromeLatest;
  2. DetectRTC.browser.isFirefoxLatest;
  3. DetectRTC.browser.isSafariLatest;
  4. DetectRTC.browser.isOperaLatest;
  5. DetectRTC.browser.isIELatest;
  6. DetectRTC.browser.isEdgeLatest;

.

.

Deactivated IndexedDB causes InvalidStateError

This call to window.indexedDB causes following exception:

InvalidStateError: A mutation operation was attempted on a database that did not allow mutations.

if you have deactivated indexedDB on firefox (not default, but possible by plugins etc).

To replicate:
set dom.indexedDB.enabled in about:config to false and call window.indexedDB from JS console.

Default audio output device missing

I've been using this library for a WebRTC-enabled chrome extension, and noticed that the Default audio output device is not showing up in DetectRTC, but is showing up when I enumerate the devices on the console.

I'm using latest Chrome.

image

image

Can anyone help me understand how to make the Default device available? Thanks!

Speaker Detection is not working

Hi,

I have tried many method to detect local speakers & checked your given example as well. But nothing is working.

Could you please me to use correct API to detect local speakers?
Thanks in Advance

Thanks,
KrishPS

Twitter in-app browser failing silently

This is less of an issue with this library (which works nicely) and more of an issue with Twitter's handling of their in-app iOS browser and it's WebRTC support. However, I figured someone might be able to point me in the right direction and greatly appreciate the help. I was very excited when iOS Safari added support for WebRTC and quickly made it a part of my work. However, I noticed that in-app browsers can be hit or miss when it comes to supporting standards. Last time I checked, Twitter and Instagram's in-app browsers did not support WebRTC but Facebook's did. Anyway, it's pretty straight-forward to look at the browser user agent to detect if the user is coming from an in-app browser or Safari directly. However... Twitter's in-app browser has the same exact user agent as the standalone Safari browser... FML. In addition, WebRTC seems to fail silently on prompting and I can't figure out a way to figure out if it's working or not. An easy test is to direct message yourself the following link on Twitter and attempt to open it within the iOS app:

https://www.webrtc-experiment.com/DetectRTC

The only thought I had was to use a timer to detect if either a positive or negative WebRTC action occurred after a specified period of time. If neither occurred, I could assume that something went wrong and encourage the user to try a different browser.

Any help is much appreciated.

Getting DetectRTC is undefined issue

Getting this issue on Internet Explorer and Safari

Unable to get property 'prototype' of undefined or null reference

on Line no 840 approx

if ('createMediaStreamSource' in window[item].prototype) {
webAudio.isCreateMediaStreamSourceSupported = true;
}

and then I get

ReferenceError: 'DetectRTC' is undefined

Live Demo: and DetectRTC.isWebSocketsSupported twice

curious
In the index.html test, why is it 2 tests using isWebSocketsSupported ?
Line 234: appendTR('Browser Supports WebSockets?', printVal(DetectRTC.isWebSocketsSupported), 'isWebSocketsSupported');
and
Line 250: appendTR('Browser Supports WebSockets API?', printVal(DetectRTC.isWebSocketsSupported), 'isWebSocketsSupported');

Xiaomi MI browser (using chromium) is not working.

Hello!
DetectRTC is not working on Xiamo MI browser which is using chromium 61.0.3163.128 under the hood.
Reproduction:

DetectRTC.load(() => {
       // this is never called
});

Any ideas if this can/will be fixed ?
Thanks.

New release please

Can you please put a new release on bower that includes the latest bug fixes?

Release 1.3.6?

I see that https://www.webrtc-experiment.com/DetectRTC/ loads https://cdn.webrtc-experiment.com/DetectRTC.js, which says it has version 1.3.6.

We are using the released version 1.3.5 from npm. When we use this version on Chrome / Android, it says hasSpeakers is false. While the testpage on webrtc-experiment says that hasSpeakers is true. When I manually added the code of DetectRTC from the master branch, things started to work (hasSpeakers === true).

Can you please make a release 1.3.6, and publish it on npm?

Local IP and Privacy Mode not working in Edge

  1. Is DetectRTC.DetectLocalIPAddress supported to work with MS Edge browsers in a default configuration? When I test with Edge 16 it does not return anything, but the same code returns the local IP in Chrome.

For instance, DetectRTC.DetectLocalIPAddress(function(ip) {alert(ip);}) doesn't show any alert.

Running your live demo shows the same issue: https://www.webrtc-experiment.com/DetectRTC/ (local IP returned in Chrome 62, but not Edge).

  1. Likewise when running in privacy mode in Edge the sample shows Nope for privacy mode whereas it should show yes (but does get it right in Chrome).

Thank you.

Initialisation slow?

Hi!

First of all: Great tool! Unfortunately I cannot get it to work.

Szenario:
Page opens. I'm calling DetectRTC.load() in my HTML right in the header after including the script and then initializing all WebRTC related stuff when $.ready is called. But when I want to use the variables like "hasWebcam" or "hasMicrophone" they're telling me that nothing was detected.
Strangest thing: when I'm debugging your lib to see what's going on, all variables are getting initialized (correctly!) and when I reach the point where it usually fails: All variables are available. So I'm heaving some kind of asynchronous issue.

In short:
without breakpoints -> not working
with -> working

Can you help me?

Thanks a lot in advance!

Potential crash during server-side rendering

If you're using SSR, the environment lacks DOM globals, but the dependencies are treated like in the browser environment. In your code, you're assigning an empty object to the document:

that.document = {};

which is a serious hazard and can simply crash any code depending on this. Here's an example of one of my dependencies (store.js):

image

Seems like React's SSR uses node-process which sets the browser property on process object:
https://github.com/defunctzombie/node-process/blob/master/browser.js#L156

Based on this fact I've prepared a quick & dirty fix:
feimosi@6a58481
Would be great if you could incorporate it into the next release or suggest a better solution.

"Please invoke getUserMedia once" on Microphones list on Android Firefox browser (v56.0)

Hi Muaz,

First, thanks for your work.

I've remark that in my application i got the "Please invoke getUserMedia once" only for the microphone list on my Android Firefox browser (v56.0).
I thougth i was doing something wrong, but if you go on this page https://www.webrtc-experiment.com/DetectRTC/ on Androïd Firefox browser you will have the "Please invoke getUserMedia once".

How to fix this issue ?

Regards,
Loïc.

Detect website Camera permission value is "Ask(default)"

Hi , I am using DetectRTC for checking microphone and camera permissions.

I need to check for if camera permission is set to "Ask(default)". The value of "isWebsiteHasWebcamPermissions" key is false even when it is actually "Ask(default)". It is not blocked nor allowed. How can I get this using DetectRTC?
Please guide me on this.
Thank you.

Type error in WebKit based browsers when doing basic detection

Running DetectRTC.isSctpDataChannelsSupported && DetectRTC.isWebRTCSupported && DetectRTC.isWebSocketsSupported on a webkit based browser (Apple Safari, Epiphany) throws a type error:

[Error] TypeError: undefined is not an object (evaluating 'window[item].prototype')
	(anonymous function) (DetectRTC.js, line 840)
	forEach ([native code], line 0)
	(anonymous function) (DetectRTC.js, line 832)
	global code (DetectRTC.js, line 1026)

Failing code is at if ('createMediaStreamSource' in window[item].prototype)

    // --------- Detect if WebAudio API are supported
    var webAudio = {
        isSupported: false,
        isCreateMediaStreamSourceSupported: false
    };

    ['AudioContext', 'webkitAudioContext', 'mozAudioContext', 'msAudioContext'].forEach(function(item) {
        if (webAudio.isSupported) {
            return;
        }

        if (item in window) {
            webAudio.isSupported = true;

            if ('createMediaStreamSource' in window[item].prototype) {
                webAudio.isCreateMediaStreamSourceSupported = true;
            }
        }
    });
    DetectRTC.isAudioContextSupported = webAudio.isSupported;
    DetectRTC.isCreateMediaStreamSourceSupported = webAudio.isCreateMediaStreamSourceSupported;

ICE Servers

@muaz-khan do you happen to know how to implement ICE Servers (STUN and TURN) it doesn't matter if the language but if its in golang it would be awesome!

IE version detection is incorrect

In IE11, the browser version is reported as 5. Even though IE doesn't support WebRTC, it would be nicer to make sure the version reported is correct.

Initial release version

Hey Muaz,

I am very happy to see this library here! In order to lock it's dependency to a specific version it would be great if you could create a release version here on GitHub.

Thanks for the bower support!

Benny

Doesn't handle refusal properly in firefox

If I dismiss the permission dialog using the close-button (which turns out to be equivalent to selecting "not now" from the popup menu) then the entire results section never shows at all.

If I explicitly choose "don't share" from the popup menu then the results section correctly shows the number of mics and cams, but all of them have the description string "Please invoke getUserMedia once.".

DetectRTC v1.27
Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0 Iceweasel/44.0.2

isWebsiteHasWebcamPermissions and isWebsiteHasMicrophonePermissions updates only to 'true'

I run an interval function that check the status of these two values (inside a DetectRTC.load call) every three seconds.

But here it comes the problem: isWebsiteHasWebcamPermissions and isWebsiteHasMicrophonePermissions are updated only if they become TRUE (i.e., when the user grants mic and camera permissions), but they don't update to FALSE if the user revoke these permissions.

In other words, after that DetectRTC finds that isWebsiteHasWebcamPermissions and isWebsiteHasMicrophonePermissions became true, it seems these two values aren't updated anymore, regardless any user interaction.

The issue occurs on both Firefox and Chrome.

Thank you in advance for your support.

Switch camera with ApplyConstraints????

In DetectRTC info page you say that:

screen shot 2018-05-04 at 18 10 37

Can you please provide an example? I think the browser will never let you do so without a an user permission...
Tried with Chrome and Firefox with this snippet:

screen shot 2018-05-04 at 18 18 31

only my first feed is shown...
nothing happens with track.applyConstraints()

Here's the output:

screen shot 2018-05-04 at 18 18 38

Crashes right away on IE Edge

SCRIPT438: Object doesn't support property or method 'indexOf'

        // trim the fullVersion string at semicolon/space if present
        if ((ix = fullVersion.indexOf(';')) !== -1) {
            fullVersion = fullVersion.substring(0, ix);
        }

Typo in sample code in readme.md

if (DetectRTC.hasSpeakers === false && (DetectRTC.broser.name === 'Chrome' || DetectRTC.broser.name === 'Edge')) {
alert('Oops, your system can not play audios.');
}

Should read browser, not boser

Checking if W3 standard version of RTCOutboundRTPStreamStats is available

Hey there. I'm currently working on a product that's using the RTCOutboundRTPStreamStats API. The API has undergone a few iterations and different browsers have implemented it differently in the past - specifically the way framesEncoded works.

Right now we're just browser detecting but it might be nice to feature detect this. Is this something that DetectRTC could/should do, or is it a little out of scope for this lib?

A bit of context:
General browser support with vendor prefixes, etc: http://caniuse.com/#feat=rtcpeerconnection
Discussion around the spec + implementation for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1348657

Reported version appears to be wrong in Safari & Edge

On Safari, the version reported is actually the Webkit version rather than the Safari version. For Safari version 10.1.1, it's currently reporting 603.2.4, which is inconsistent with how other places report Safari versions.
The cause is that the current mechanism we have for detecting Safari doesn't support Safari 10+.

var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;

Suggested fix: update that line.

On Edge browser, DetectRTC is not reporting the major version number.
E.g. on Windows 10, I expect the reported version to be 15.15063, and yet it's only reporting 15063.
This appears to be an intentional choice.

fullVersion = parseInt(navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)[2], 10).toString();

This line strips out the major version number. The line immediately above
// fullVersion = navigator.userAgent.split('Edge/')[1];

would report both major and minor version number.

This is not consistent with how Edge versions are normally reported. In the following links, Edge version is identified by major version number only.
https://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0
https://analytics.usa.gov/data/
http://caniuse.com/#feat=rtcpeerconnection

Suggested fix: uncomment line 80 and remove line 81.

DetectRTC.load() "has*" properties are not reset to false

Hey!

When calling DetectRTC.load() and webcam is plugged, DetectRTC.hasWebcam value is set to true. But when unplugging my webcam and calling DetectRTC.load(), DetectRTC.hasWebcam value is still set to true.

I purpose you to set hasMicrophone/hasSpeakers/hasWebcam to false as you set audioInputDevices = []; ... in the function getIPs(callback). What do you think ?

Not finding all videoinputs

Trying this on an android phone with two cameras. I can see both cameras if I manually enumerate devices but DetectRTC only shows the one. See below:
videoinputdevices

Deprecation Warning in Chrome

'webkitAudioContext' is deprecated. Please use 'AudioContext' instead.

Version 46.0.2490.86 (64-bit) 
Google Chrome is up to date.

['AudioContext', 'webkitAudioContext', 'mozAudioContext', 'msAudioContext'].forEach(function(item) {

Cannot read property 'indexOf' of undefined

the problem is related to function

function afterCreateOffer() {
  var lines = pc.localDescription.sdp.split('\n');

  lines.forEach(function(line) {
      if (line.indexOf('a=candidate:') === 0) {
          handleCandidate(line);
      }
  });
}

https://github.com/muaz-khan/DetectRTC/blob/master/DetectRTC.js#L647

I think it should be

function afterCreateOffer() {
  var lines = pc.localDescription.sdp.split('\n');

  lines.forEach(function(line) {
      if (line && line.indexOf('a=candidate:') === 0) {
          handleCandidate(line);
      }
  });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.