无法在屏幕上看到远程系统视频

时间:2014-04-24 13:27:39

标签: opentok video-conferencing

您是否有任何有关视频合作的演示。我刚刚创建了一个代码但无法在屏幕上看到远程计算机视频,而在远程系统屏幕上看不到我的视频。

这是我的代码

<head runat="server">
<script src="//static.opentok.com/webrtc/v2.2/js/opentok.min.js" ></script>
<script type="text/javascript">
    var remoteVideo = document.getElementById('remoteVideo');
    var apiKey = "Key";
    var sessionId = "*session*";
    var token = "*token*";

    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], div.id);
    }
    });

    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);
    }
    });
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="myPublisherDiv" style="width:320px; height:240px; background-color:#ffffff"></div>
<div id="remoteVideo" style="width:320px; height:240px; background-color:#ffffff"></div>
</form>
</body>

您可以提供任何演示或解决此代码中的错误。 无法在屏幕上看到远程系统视频。

和Manish

1 个答案:

答案 0 :(得分:1)

以下是一些示例代码。您将尝试使用旧版本的API。以下是群组视频聊天的示例代码。请务必使用您自己的凭据替换apiKey,sessionId和token。祝你好运!

<!DOCTYPE html>
<html>
<head></head>
<body>

  <script src='//static.opentok.com/webrtc/v2.2/js/opentok.min.js'></script>
  <script>
    var apiKey = "apiKey";
    var sessionId = "sessionId";
    var token = "Token";

    var session = OT.initSession(apiKey, sessionId);
    session.connect( token, function(err){
      if(!err){ session.publish(); }
    });
    session.on("streamCreated", function(event){
      session.subscribe( event.stream );
    }); 
  </script>
</body>
</html>