Last active
January 1, 2016 01:38
-
-
Save payload/8073770 to your computer and use it in GitHub Desktop.
A little example to get plava client library started.
This file contains 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" /> | |
<title>Meine erste Videoapplikation</title> | |
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<script src="https://raw.github.com/Wolfy87/EventEmitter/master/EventEmitter.min.js"></script> | |
<script src="https://raw.github.com/palavatv/palava-client/master/palava.min.js"></script> | |
<script type="text/coffeescript"> | |
channel = new palava.WebSocketChannel('wss://machine.palava.tv') | |
session = new palava.Session | |
roomId: "test" | |
channel: channel | |
session.on 'local_stream_ready', (stream) -> | |
palava.browser.attachMediaStream($('#myvideo'), stream) | |
session.room.join() | |
session.on 'peer_stream_ready', (peer) -> | |
if peer.isLocal() | |
return | |
if $('#' + peer.id).length > 0 | |
element = $('#' + peer.id) | |
$('#others').append(element) | |
else | |
element = $('<li id="' + peer.id + '"><video autoplay></video></li>') | |
palava.browser.attachMediaStream(element.children('video')[0], peer.getStream()) | |
session.on 'peer_left', (peer) -> | |
$('#' + peer.id).remove() | |
session.init | |
identity: new palava.Identity | |
userMediaConfig: | |
audio: true | |
video: true | |
options: | |
stun: 'stun:stun.palava.tv' | |
joinTimeout: 500 | |
</script> | |
<script type="text/javascript" src="https://raw.github.com/jashkenas/coffee-script/master/extras/coffee-script.js"></script> | |
</head> | |
<body> | |
<h2>Mein Video</h2> | |
<video id="myvideo" autoplay></video> | |
<h2>Andere Videos:</h2> | |
<ul id="others"></ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment