HenrikJoreteg / webrtcsupport

Browser module to detect support for WebRTC and extract proper constructors.
55 stars 33 forks source link

support unprefixed vendors #18

Closed yocontra closed 9 years ago

yocontra commented 9 years ago

there are plenty of vendors in the wild without prefixes (iosrtc) so why does this not work with those?

RangerMauve commented 9 years ago

In terms of iosRTC, they can't provide the globals until the "deviceready" event is emitted. This module detects the globals when it's initially required, so you might have a timing issue.

+1 for supporting unprefixed modules, though.

yocontra commented 9 years ago

@RangerMauve Sure, but that isn't of any concern to this module or any other one.

document.addEventListener('deviceready', function(){
  var rtc = require('webrtcsupport');
  // do your stuff
});

and for temasys it would be

var adapter = require('adapterjs');
adapter.webRTCReady(function(){
  var rtc = require('webrtcsupport');
  // do your stuff
});

Want a web app that can use WebRTC in any browser, node, and any mobile device?

// quick pseudo-code
function getRTC(cb){
  // nodejs
  if (typeof document === 'undefined') {
    cb(require('wrtc'));
  }

  // ios via cordova
  if (window.device && window.device.platform === 'iOS') {
    document.addEventListener('deviceready', function(){
      cordova.plugins.iosrtc.registerGlobals();
      cb(require('webrtcsupport'));
    });
  }
  // all desktop browsers + android
  require('adapterjs').webRTCReady(function(){
    cb(require('webrtcsupport'));
  });
}

getRTC(function(webrtc){
  // congrats, do your stuff
});

Too bad webrtcsupport (and the whole ecosystem of modules that rely on it) are stuck on chrome/firefox only because they want to neglect this simple fix 😱

RangerMauve commented 9 years ago

I agree fully.

fippo commented 9 years ago

Your concern is that this module doesn't do

var PC = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;

?

Interested how you're getting this to work in Microsoft Edge (since you said 'any browser)

RangerMauve commented 9 years ago

My hope is that edge will hurry up with their ORTC crap so that someone can polyfill WebRTC on top of it.

yocontra commented 9 years ago

@fippo temasys is going to handle edge in the future https://github.com/Temasys/AdapterJS/issues/99

Also yes, the issue was that simple and easy to fix, which is why I was so confused about why it was open for so long and such a problem to fix.

yocontra commented 9 years ago

I think there still might be some problems with the way the browser detection is done (since it assumes if webkitPeerConnection exists then it is chrome, even though webkitPeerConnection can also exist on safari/ie via temasys) but I will open further tickets as needed. Thank you for fixing this.

RangerMauve commented 9 years ago

My take on the version/prefix part of this library is that it's not 100% needed.

fippo commented 9 years ago

I have gradually gotten rid of this library actually in favor of adapter. But things take time.