简体   繁体   中英

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. I feel like I'm going through the same thing in 2016 with 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. But it doesn't work in my 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? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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