【问题标题】:unable to see remote system video on my screen无法在我的屏幕上看到远程系统视频
【发布时间】:2014-04-24 13:27:38
【问题描述】:

您有任何关于视频会议的演示吗?我刚刚创建了一个代码,但无法在我的屏幕上看到远程计算机视频,也无法在远程系统屏幕上看到我的视频。

这是我的代码

<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>

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

风度翩翩

【问题讨论】:

    标签: opentok video-conferencing


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多