Created
May 31, 2013 08:23
-
-
Save KensakuKOMATSU/5683589 to your computer and use it in GitHub Desktop.
peer.js in avstream
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<script src="peer.js"></script> | |
<video id="local"></video> | |
<video id="remote"></video> | |
<button id="start0">start as 0(caller)</button> | |
<button id="start1">start as 1(callee)</button> | |
<script> | |
document.querySelector('#start0').onclick = function(ev){ | |
var peer = new Peer('0', { "host": "localhost", "port": 9000}); | |
var call = peer.call('1') | |
call.on('localstream', function(stream){ | |
console.log(stream); | |
var url = window.URL.createObjectURL(stream); | |
console.log(url); | |
document.querySelector('#local').setAttribute("src", url) | |
}) | |
call.on('remotestream', function(stream){ | |
console.log(stream); | |
}) | |
} | |
document.querySelector('#start1').onclick = function(ev){ | |
var peer = new Peer('1', { "host": "localhost", "port": 9000}); | |
peer.on('localstream', function(stream){ | |
console.log(stream); | |
}) | |
peer.on('remotestream', function(stream){ | |
console.log(stream); | |
}) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment