Created
May 14, 2015 18:48
-
-
Save wfaler/33a860b75496e495b9f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function getParameterByName(name) { | |
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); | |
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | |
results = regex.exec(location.search); | |
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | |
} | |
var webrtc = new SimpleWebRTC({ | |
// the id/element dom element that will hold "our" video | |
localVideoEl: 'localVideo', | |
// the id/element dom element that will hold remote videos | |
remoteVideosEl: 'remoteVideos', | |
// immediately ask for camera access | |
autoRequestMedia: true, | |
url: 'http://192.168.1.101:8888/' | |
}); | |
webrtc.on('readyToCall', function () { | |
var room = getParameterByName('room'); | |
// you can name it anything | |
console.log('joining room..' + room); | |
webrtc.joinRoom(room); | |
}); | |
webrtc.on('videoAdded', function (video, peer) { | |
console.log('video added', peer); | |
var remotes = document.getElementById('remoteVideos'); | |
if (remotes) { | |
var container = document.createElement('div'); | |
container.className = 'videoContainer'; | |
container.id = 'container_' + webrtc.getDomId(peer); | |
container.appendChild(video); | |
video.oncontextmenu = function () { return false; }; | |
remotes.appendChild(container); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment