- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用此处找到的 SimpleWebRTC 库:https://simplewebrtc.com
我的信号主站正在运行,并且 STUN/TURN 配置正确。它能够检测其他对等点,因此我认为 STUN/TURN 功能正常。我的问题是,当一个对等方开始其本地视频时,其他对等方不会发现它,除非他们重新加载页面。我想要它,这样它就会自动推送到其他对等点,而不需要重新加载页面。我认为这与下面的代码有关(我从示例中获取),但我不确定。
我将 autoRequestMedia 设置为 false 的原因是因为我希望用户能够查看其他对等方的摄像头,而无需打开自己的设备(也是我在 readToCall 事件中没有 webrtc.joinRoom 的原因)。
目前,用户点击按钮,会触发startLocalVideo();并且视频是在元素中创建的。问题是除非其他对等点重新加载页面,否则不会将任何内容推送到其他对等点。希望这能解释一切,如果您需要更多详细信息,请告诉我。
var webrtc = new SimpleWebRTC({
// the id/element dom element that will hold "our" video
localVideoEl: 'localCam',
// the id/element dom element that will hold remote videos
remoteVideosEl: '',
// immediately ask for camera access
autoRequestMedia: false,
autoRemoveVideos: true,
url: 'MY SIGNAL-MASTER URL HERE',
localVideo: {
autoplay: true, // automatically play the video stream on the page
mirror: false, // flip the local video to mirror mode (for UX)
muted: true // mute local video stream to prevent echo
}
});
webrtc.joinRoom('testchannel');
// a peer video has been added
webrtc.on('videoAdded', function (video, peer) {
console.log('video added', peer);
var remotes = document.getElementById('remoteCams');
if (remotes) {
var container = document.createElement('div');
container.className = 'videoContainer';
container.id = 'container_' + webrtc.getDomId(peer);
container.appendChild(video);
// suppress contextmenu
// video.oncontextmenu = function () { return false; };
remotes.appendChild(container);
}
});
// a peer video was removed
webrtc.on('videoRemoved', function (video, peer) {
console.log('video removed ', peer.nick);
var remotes = document.getElementById('remoteCams');
var el = document.getElementById(peer ? 'container_' + webrtc.getDomId(peer) : 'localScreenContainer');
if (remotes && el) {
remotes.removeChild(el);
}
});
最佳答案
您必须将 join 语句放入 readyToCall 监听器中:
webrtc.on('readyToCall', function() {
webrtc.joinRoom('roomname');
})
或
将 joinRoom 调用放入 setTimout 函数中。
关于javascript - SimpleWebRTC 对等发现无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43578472/
我正在使用此处找到的 SimpleWebRTC 库:https://simplewebrtc.com 我的信号主站正在运行,并且 STUN/TURN 配置正确。它能够检测其他对等点,因此我认为 STU
我正在使用This WebRtc 的 jQuery 插件 我只想开始音频通话,但我看不到任何相关功能。我正在使用以下代码使用 autoRequestMedia:false :- webrtc = n
我正在使用 simpleWebRTC 进行多方视频聊天。 每个用户创建自己的房间。当一个用户订阅另一个用户时(为了看到这个人 0 并在数据库中注册)。 当用户选择另一个时 - 他通过 XHR 从数据库
我正在尝试集成 SimpleWebRtc。我创建了一个新组件并集成了我在 SimpleWebRtc 网站上找到的代码并收到错误: ReferenceError: window is not defin
我正在做一个simpleWebRTC 演示来创建直播 session 。 我想要实现的是: 人是领导者。领导可以播放他的音频和视频。 其余加入的都是追随者。他们只能看到和听到领导的广播。 为了在常规w
我正在使用 SimpleWebRTC API,但在教程中我们没有讨论断开连接的地方。我怎样才能停止广播? 最佳答案 根据您的需要(终止一个节点或所有节点),leaveRoom() 或调用节点的 end
我正在使用 simpleWebRTC 和 xhr 来实现特殊的多用户视频聊天(无音频)简而言之,我的主要问题是:我无法将 php 中的用户名附加到 JS 中的正确视频 在我的问题中我会 1. 解释一下
我是菜鸟,开始学习webRTC,最近发现一个叫simplewebrtc的网页,看了demo,但是不明白他们是怎么管理防火墙和NAT穿越的网络,我知道 webRTC 使用 STUN 服务器,但我在 si
你好我是新学习 WebRTC,我有点困惑,我知道 WebRTC 可以点对点工作,但我们需要信号,SimpleWebRTC、EasyRTC 和 Kurento 中的哪一个可以帮助做到这一点,如果是 no
我是一名优秀的程序员,十分优秀!