...
To analyze the code, let's take the version of file 2players.js with hash cf0daabc6b86e21d5a2f9e4605366c8b7f0d27eb66cc393, which is available here and and can be downloaded with corresponding build 0.5.328.182753.1894133.
Functions of initialization, creating stream, starting and stopping playback work the same as described in the example Player.
1. Two <div> elements creation
Code Block | ||||
---|---|---|---|---|
| ||||
<div id="player1" class="display"></div> |
Code Block | ||||
---|---|---|---|---|
| ||||
<div id="player2" class="display"></div> |
2. The element is passed as parameter 'display' when the stream for playback is created
document.getElementById(), session.createStream() code
Code Block | ||||
---|---|---|---|---|
| ||||
var display = document.getElementById("player" + index);
|
session.createStream() code
Code Block | ||||
---|---|---|---|---|
| ||||
session.createStream({ name: streamName, display: display }).on(STREAM_STATUS.PLAYINGPENDING, function(stream) { ... }).play(); |
So, for each stream <div> element 'display' can be passed, and any number of video streams can be played on one HTML page.