![](/img/trans.png)
[英]WebRTC connectionState stuck at "new" - Safari only, works in Chrome and FF
[英]WebRTC video chat works in FF but not in Chrome
早在1997年,一页在IE中看起来不错,但同一页在Netscape中看起来很烂。 我觉得我在2016年通过WebRTC经历了同样的事情。 我创建了聋人社交媒体。 现在,他们可以聊天和发布消息。 我想添加视频会议,每个邮政编码和每个城市/州都有一个“房间”。 这是其中一个房间的公共链接(邮政编码)。
https://ikasl.azurewebsites.net/m/vface.aspx?area=94519
因此,我们将某些东西放在一起可以在FF中完美运行。 但这在我的Chrome中不起作用。 我得到的是一个黑匣子。 浏览器日志(控制台)已清除。 没有错误。 有人认为此代码仅在FF中有效吗? 谢谢
var openVideoChat = function () {
if (chatIsOpened) { return false; };
var connection = new RTCMultiConnection();
connection.socketURL = herokuURL;
connection.socketMessageEvent = 'video-conference-demo';
connection.session = { audio: true, video: true };
connection.sdpConstraints.mandatory = { OfferToReceiveAudio: true, OfferToReceiveVideo: true };
connection.videosContainer = document.getElementById('videos-container');
connection.onstream = function(event) {
var width = parseInt(connection.videosContainer.clientWidth / 2) - 20;
var mediaElement = getMediaElement(event.mediaElement, {
title: event.userid,
buttons: [
'full-screen',
'mute-audio',
'mute-video',
'stop',
'stop-others'
],
width: width,
showOnMouseEnter: true
});
connection.videosContainer.appendChild(mediaElement);
setTimeout(function() { mediaElement.media.play(); }, 5000);
mediaElement.id = event.streamid;
};
connection.onstreamended = function(event) {
var mediaElement = document.getElementById(event.streamid);
if(mediaElement) { mediaElement.parentNode.removeChild(mediaElement); }
};
connection.openOrJoin(roomid);
chatIsOpened = true;
var bitrates = {
audio: connection.bandwidth.audio,
screen: connection.bandwidth.screen,
video: connection.bandwidth.video,
};
var bitrateIndicatorEl = document.getElementById('bitrateIndicator');
bitrateIndicatorEl.innerHTML = ('Bitrates: [audio: <b>' + bitrates.audio
+ ' kbps</b>] [your: <b>' + bitrates.screen
+ ' kbps</b>] [others: <b>' + bitrates.video + ' kbps</b>]');
};
var modal = new tingle.modal({
footer: true,
stickyFooter: false,
onOpen: function () { },
onClose: function () { }
});
modal.setContent('<div id="videos-container"</div><div id="bitrateIndicator"></div>');
modal.addFooterBtn('Close popup', 'tingle-btn tingle-btn--primary', function () {
modal.close();
});
这行对我来说很奇怪:
setTimeout(function() { mediaElement.media.play(); }, 5000);
您应该只在媒体元素上设置autoplay: true
,所以它会自动播放。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.