【问题标题】:Only one frame displayed WebRTC stream只显示一帧 WebRTC 流
【发布时间】:2013-12-29 06:45:54
【问题描述】:

我正在使用 PeerJS 及其云托管服务器来构建 WebRTC 应用程序。这是我的代码:

navigator.getMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);

window.URL = window.URL || window.webkitURL;

var callSettings = {
  video: {
    mandatory: {
      maxWidth: 400,
      maxHeight: 300
    }
  },
  audio: true
};

$(document).ready(function ()
{
    var videoel = $("#teacher-stream")[0];

    $(document).on('click', ".start-call", function () //A button initiates call
    {
        var peerID = $(this).data('id'); //Button contains ID of peer
        navigator.getMedia(callSettings, function (stream)
        {
            var call = peer.call(peerID, stream);
            call.on('stream', function(remoteStream)
            {
                console.log('stream!');
                videoel.src = window.URL.createObjectURL(remoteStream);
                            //On stream copy data to video el

            });
        });
    });

    peer.on('call', function(call)
    {
        console.log('got call');
        navigator.getMedia(callSettings, function(stream)
        {
            call.answer(stream);
            call.on('stream', function(remoteStream)
            {
                videoel.src = window.URL.createObjectURL(remoteStream);

            });
        });
    });

});

流启动,两个用户都被请求授予网络摄像头访问权限。但是,在此之后,仅显示第一帧。虽然 Chrome 选项卡上的脉冲记录图标仍然显示,但没有显示更多帧。 “流!”上面的日志只添加一次。

我已尝试在本地托管服务器以检查这是否是问题所在,但事实并非如此。我错过了什么?

【问题讨论】:

    标签: javascript webcam webrtc peerjs


    【解决方案1】:

    我需要将属性“autoplay = true”添加到我的视频元素中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-28
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-13
      相关资源
      最近更新 更多