我正在做一个simpleWebRTC 演示
来创建直播 session 。
我想要实现的是:
- 人是领导者。领导可以播放他的音频和视频。
- 其余加入的都是追随者。他们只能看到和听到领导的广播。
为了在常规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/