简体   繁体   English

WebRTC视频聊天只能在FF中使用,而不能在Chrome中使用

[英]WebRTC video chat works in FF but not in Chrome

Back in 1997, one page would look good in IE but the same page would look broken in Netscape. 早在1997年,一页在IE中看起来不错,但同一页在Netscape中看起来很烂。 I feel like I'm going through the same thing in 2016 with WebRTC. 我觉得我在2016年通过WebRTC经历了同样的事情。 I've created a social media for deaf. 我创建了聋人社交媒体。 Right now they can chat and post messages. 现在,他们可以聊天和发布消息。 I want to add video conferencing where every zip code and every city/state have a "room." 我想添加视频会议,每个邮政编码和每个城市/州都有一个“房间”。 Here's the public link to one of the rooms (zip code). 这是其中一个房间的公共链接(邮政编码)。

https://ikasl.azurewebsites.net/m/vface.aspx?area=94519

So we put something together that works perfectly in FF. 因此,我们将某些东西放在一起可以在FF中完美运行。 But it doesn't work in my Chrome. 但这在我的Chrome中不起作用。 What I get is a black box. 我得到的是一个黑匣子。 Browser logs (console) are clear. 浏览器日志(控制台)已清除。 No errors. 没有错误。 Does anyone see anything wrong with this code that makes it only work in FF? 有人认为此代码仅在FF中有效吗? Thanks 谢谢

            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();
        });

This line looks weird to me: 这行对我来说很奇怪:

setTimeout(function() { mediaElement.media.play(); }, 5000);

You should just set autoplay: true on your media element, so it plays automatically. 您应该只在媒体元素上设置autoplay: true ,所以它会自动播放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM