Last active
August 29, 2015 14:24
-
-
Save KensakuKOMATSU/c4ade4b79d8394c6e3d0 to your computer and use it in GitHub Desktop.
one way video streaming sample gist
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"> | |
<script src="https://skyway.io/dist/0.3/peer.js"></script> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
</head> | |
<body> | |
<h1>callee</h1> | |
myid: <input id="myid" type="number" readonly><br> | |
<p> | |
<h2>received video streaming</h2> | |
<video autoplay></video> | |
</p> | |
<script> | |
var myid = Math.floor(Math.random() * 10000), stream, peer; | |
$("#myid").val(myid); | |
var peer = new Peer(myid, {"key": "7b5cadc4-5364-4677-9e6f-8055555592fd"}); | |
peer.on("open", function(){ | |
peer.on("call", function(call) { | |
call.answer(undefined); // use falsy value ( null, undefined, 0, "", false, NaN ) | |
call.on("stream", function(stream) { | |
$("video").attr("src", window.URL.createObjectURL(stream)); | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
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"> | |
<script src="https://skyway.io/dist/0.3/peer.js"></script> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
</head> | |
<body> | |
<h1>caller</h1> | |
peerid:<input type="number"> <button>start streaming</button> | |
<p> | |
<h2>my video</h2> | |
<video autoplay></video> | |
</p> | |
<script> | |
navigator.getUserMedia = navigator.getUserMedia || | |
navigator.webkitGetUserMedia || | |
navigator.mozGetUserMedia; | |
$("button").on("click", function(ev){ | |
navigator.getUserMedia({"video": true, "audio": false}, function(stream) { | |
var peerid = $("input").val(); | |
if(!peerid) throw "peerid does not specified"; | |
peer = new Peer({"key": "7b5cadc4-5364-4677-9e6f-8055555592fd"}); | |
peer.on("open", function(){ | |
var call = peer.call(peerid, stream); | |
call.on("stream", function(s) { | |
// this never fired in this use case ;-) | |
}); | |
}); | |
}, function(err) { | |
throw err; | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment