2013-07-11 1 views
1

들어오는 비디오 스트림이 본체 아래쪽에 연결됩니다.OpenTok 들어오는 비디오 스트림이 본체 아래쪽에 연결됨

<div id="myPublisherDiv" style="width:320px; height:240px; background-color:#ffffff"></div> 
<div id="remoteVideo" style="width:320px; height:240px; background-color:#ffffff"></div> 

여기 내 자바 스크립트입니다 : 당신의 sessionConnected 이벤트 핸들러에서

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); 
    } 
}); 

답변

3

, 당신은 subscribe 함수에 DIV ID를 전달해야 내 HTML에서 나는 두 개의 div가 있습니다. (Documentation)

session.subscribe(e.streams[i], div.id); 
관련 문제