Feature detect with Modernizr

* A start on #34
This commit is contained in:
Arlo Breault 2016-04-05 10:27:41 -07:00
parent 0f952408d3
commit d567e2312f
10 changed files with 52 additions and 33 deletions

View file

@ -2,13 +2,19 @@
WebrTC shims for multiple browsers.
###
if 'undefined' != typeof module && 'undefined' != typeof module.exports
console.log 'not in browser.'
if typeof module isnt 'undefined' and module.exports
window = {}
else
window.PeerConnection = window.RTCPeerConnection ||
window.mozRTCPeerConnection ||
window.webkitRTCPeerConnection
window.RTCIceCandidate = window.RTCIceCandidate || window.mozRTCIceCandidate
window.RTCSessionDescription = window.RTCSessionDescription ||
window.mozRTCSessionDescription
window = this
prop = Modernizr.prefixed 'RTCPeerConnection', window, false
if not prop
console.log 'webrtc feature not detected. shutting down'
return;
PeerConnection = window[prop]
### FIXME: push these upstream ###
IceCandidate = window.RTCIceCandidate || window.mozRTCIceCandidate
SessionDescription = window.RTCSessionDescription || window.mozRTCSessionDescription
location = if window.location then window.location.search.substr(1) else ""