着信ビデオ ストリームは、本体の下部に接続されています。私のhtmlには、次の2つのdivがあります。
<div id="myPublisherDiv" style="width:320px; height:240px; background-color:#ffffff"></div>
<div id="remoteVideo" style="width:320px; height:240px; background-color:#ffffff"></div>
これが私のJavaScriptです:
var remoteVideo = document.getElementById('remoteVideo');
var apiKey = "xxxx";
var sessionId = "xxxx";
var token = "xxxx";
var publisher = TB.initPublisher(apiKey, 'myPublisherDiv');
var session = TB.initSession(sessionId);
session.addEventListener('sessionConnected', function(e){
session.publish( publisher );
for (var i = 0; i < e.streams.length; i++) {
if (e.streams[i].connection.connectionId == session.connection.connectionId) {
return;
}
var div = document.createElement('div');
div.setAttribute('id', 'stream' + e.streams[i].streamId);
remoteVideo.appendChild(div);
session.subscribe(e.streams[i]);
}
});
session.addEventListener('streamCreated', function(e){
for (var i = 0; i < e.streams.length; i++) {
if (e.streams[i].connection.connectionId == session.connection.connectionId) {
return;
}
var div = document.createElement('div');
div.setAttribute('id', 'stream' + e.streams[i].streamId);
remoteVideo.appendChild(div);
session.subscribe(e.streams[i], div.id);
}
});