首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SimpleWebRTC中获取约束对象

在SimpleWebRTC中获取约束对象
EN

Stack Overflow用户
提问于 2014-07-02 01:33:30
回答 1查看 440关注 0票数 3

我正在做一个simpleWebRTC demo来创建livestream会话。

我想要做到的是:

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

要在常规的webRTC中这样做,我们有一个约束对象,其中我们可以说:

代码语言:javascript
复制
{audio: false, video: false}

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

如何使用simpleWebRTC完成这一任务

EN

回答 1

Stack Overflow用户

发布于 2015-05-31 05:52:36

因此,我在这里发现了这样一个文档:(https://simplewebrtc.com/notsosimple.html):

代码语言:javascript
复制
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
});

或者您必须修改库:

代码语言:javascript
复制
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})

然后

代码语言:javascript
复制
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/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24521593

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档