Skip to content

Instantly share code, notes, and snippets.

@benjamingr
Last active August 31, 2017 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamingr/d085d24b6eb70b1dccf9baeae3b8c0dd to your computer and use it in GitHub Desktop.
Save benjamingr/d085d24b6eb70b1dccf9baeae3b8c0dd to your computer and use it in GitHub Desktop.
This code snippet lets you load Peer5 without
// 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();
}
// 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