Skip to content

Instantly share code, notes, and snippets.

@KensakuKOMATSU
Created May 31, 2013 08:23
Show Gist options
  • Save KensakuKOMATSU/5683589 to your computer and use it in GitHub Desktop.
Save KensakuKOMATSU/5683589 to your computer and use it in GitHub Desktop.
peer.js in avstream
<!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