google-chrome - 在 SimpleWebRTC 中获取约束对象

标签 google-chrome constraints webrtc getusermedia

我正在做一个simpleWebRTC 演示来创建直播 session 。

我想要实现的是:

  1. 人是领导者。领导可以播放他的音频和视频。
  2. 其余加入的都是追随者。他们只能看到和听到领导的广播。

为了在常规webRTC中做到这一点,我们有约束对象,其中我们可以说:

{audio: false, video: false}

但是,在simpleWebRTC对象中,我没有看到暴露的约束对象

如何使用simpleWebRTC完成此任务?

最佳答案

所以我发现这个文档在这里说( https://simplewebrtc.com/notsosimple.html ):

var webrtc = new SimpleWebRTC({
  localVideoEl: 'localVideo',
  remoteVideosEl: 'remotesVideos',
  autoRequestMedia: true,
  url: 'https://example.com/'
  //use the media options to pass constraints for getUserMedia requests
  media: mediaOptions
});

或者你必须修改库:

SimpleWebRTC.prototype.startLocalVideo = ->
  self = this
  this.config.constraints ||= {video: true, audio: true}
  this.webrtc.startLocalMedia this.config.constraints, (err, stream)->
    if err
      self.emit(err)
    else
      attachMediaStream(stream,
        self.getLocalVideoContainer(),
        {muted: true, mirror: true})

然后

webrtc = new SimpleWebRTC
  localVideoEl: 'localVideo'
  remoteVideosEl: 'remotes'
  autoRequestMedia: true
  debug: true
  detectSpeakingEvents: true
  autoAdjustMic: false
  constraints:
    audio: true
    video:
      mandatory:
        maxWidth: 320
        maxHeight: 180

这是破解方法 http://blog.dev.zyncro-china.com/2014/02/25/hacking-simplewebrtc-js-to-change-the-video-resolution/

关于google-chrome - 在 SimpleWebRTC 中获取约束对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24521593/

相关文章:

swift - 在编程 collectionviewCell 中添加约束

ios - UICollection View 根据屏幕大小调整单元格大小

android - 如何向发送和接收的 WebRTC 视频轨道添加模糊和背景模糊

javascript - Chrome 控制台错误 "Uncaught SyntaxError: Invalid or unexpected token"?

google-chrome - 安装扩展后如何打开新标签页?

javascript - 受密码保护的 Chrome 扩展程序

google-chrome - 丢失的 Chrome 标签,真的有些愚蠢的情况仍然可以挽救吗?

ios - 如何为 UITableView 下面具有可变高度的项目设置约束

android - WebRTC Native Android Switch 音源?

html - WebRTC:对等连接限制?