![](/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.