public
Last active

A little example to get plava client library started.

  • Download Gist
palava-example.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<!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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.