Last active
August 31, 2017 08:13
-
-
Save benjamingr/d085d24b6eb70b1dccf9baeae3b8c0dd to your computer and use it in GitHub Desktop.
This code snippet lets you load Peer5 without
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load Peer5 with a script timeout | |
var initiated; | |
function initClappr() { | |
if (initiated) return; | |
initiated = true; | |
// var player = new Clappr.Player(); | |
// rest of clappr initialization | |
} | |
function isPeer5Supported() { | |
var hasWebRTC = Boolean(window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection); | |
var hasWebSockets = window.WebSocket; | |
return Boolean(hasWebRTC && hasWebSockets) | |
} | |
if (isPeer5Supported()) { | |
var s = document.createElement('script'); | |
s.src = '//api.peer5.com/peer5.js?id=xxxxxxxxxxxxxxxxxxxx'; | |
s.onload = initClappr; | |
setTimeout(initClappr, 4000); | |
} else { | |
initClappr(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load Peer5 with a script timeout | |
var initiated; | |
function initClappr() { | |
if (initiated) return; | |
initiated = true; | |
// var player = new Clappr.Player(); | |
// rest of clappr initialization | |
} | |
var s = document.createElement('script'); | |
s.src = '//api.peer5.com/peer5.js?id=xxxxxxxxxxxxxxxxxxxx'; | |
s.onload = initClappr; | |
setTimeout(initClappr, 4000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment