3

I'm using SimpleWebRTC to have a video conference, but the problem is that FireFox works properly but chrome and other browsers even don't show the popup for allowing it to use webcam or microphone.

Please help me how I can fix it.

Appreciation

my code:

<script src="js/jquery-2.2.0.js"></script>
<script src="js/latest-v2.js"></script>

<button class="btn btn-danger" id="show" onclick="play();">btn1</button>
<button class="btn btn-danger" id="hide" style="display: none;" onclick="pause();">btn2</button>

<video class="paused localVideo" id="localVideo"></video>
<div id="import">

</div>

<script type="text/javascript">
    function play()
    {
        webrtc.resumeVideo();
        $('.localVideo').removeClass('paused');
        $("#show").hide();
        $("#hide").show();
    }
    function pause()
    {
        webrtc.pauseVideo();
        $('.localVideo').addClass('paused');
        $("#show").show();
        $("#hide").hide();
    }

    function unmute()
    {
        webrtc.unmute();
        $('.localVideo').removeClass('muted');
    }
    function mute()
    {
        webrtc.mute();
        $('.localVideo').addClass('muted');
    }

    function type()
    {
        // some IFs here
        $('#import').css('someAttribute','someValue');
        $('.remoteVideos').css('someAttribute','someValue');
        return true;
    }

    var webrtc = new SimpleWebRTC({
        localVideoEl: 'localVideo',
        remoteVideosEl: '',
        autoRequestMedia: true,
        media: {
            video: type(),
            audio: type()
        },
    });

    webrtc.on('readyToCall', function () {
        var class_name = "<?php echo $class_name; ?>";
        webrtc.joinRoom(class_name);
    });

    webrtc.on('mute', function(data) {
        if(data.name === 'video')
            $('.remoteVideos').addClass('paused');
        else if(data.name === 'audio')
            $('.remoteVideos').addClass('muted');
    });

    webrtc.on('unmute', function(data) {
        if(data.name === 'video')
            $('.remoteVideos').removeClass('paused');
        else if(data.name === 'audio')
            $('.remoteVideos').removeClass('muted');
    });

    webrtc.on('videoAdded', function(video, peer) {
        remotes = document.getElementById('import');
        container = document.createElement('div');
        container.className = "paused remoteVideos col-xs-5";
        container.appendChild(video);
        remotes.appendChild(container);
        $('#'+video.id).parent().removeClass('paused');
        $('#'+video.id).parent().removeClass('muted');
        type();

        if (peer && peer.pc)
        {
            peer.pc.on('iceConnectionStateChange', function (event)
            {
                if(peer.pc.iceConnectionState == 'closed')
                {
                    $('#'+video.id).parent().addClass('paused');
                    $('#'+video.id).parent().addClass('muted');
                }
            });
        }
    });
</script>
Arya Basiri
  • 177
  • 2
  • 14
  • You need to give more details here. Usually Chrome does not show a popup, but there's a webcam icon next to the address bar. You need to click on it and select "Allow ..." – Adrian Ber Feb 22 '16 at 11:41
  • No dear, I'm sure that it is something in my code, because when I go to talky.io it pops up. – Arya Basiri Feb 22 '16 at 11:59
  • Then you need to provide more details. – Adrian Ber Feb 22 '16 at 12:32
  • OK I will write the code... – Arya Basiri Feb 22 '16 at 12:35
  • 3
    Are you using [https](http://stackoverflow.com/a/35374091/918910)? – jib Feb 22 '16 at 19:50
  • No, it's simple HTTP. – Arya Basiri Feb 23 '16 at 05:43
  • Heeey guys! I got it, as @jib said it caused by not having that 's' at the end! What I want to do now is to use htaccess file to force the site to use ssl by this code: `RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.amozesheshahrvandi.ir/$1 [R,L]` however the error is: 'Secure Connection Failed' (for FireFox) and 'This webpage is not available' (for Chrome), could you help me how I can fix this only by code not by buying ssl certificate. THANKS – Arya Basiri Feb 23 '16 at 13:21
  • Possible duplicate of [openwebrtc demo is not working in Chrome](http://stackoverflow.com/questions/35359138/openwebrtc-demo-is-not-working-in-chrome) – jib Feb 23 '16 at 13:34

0 Answers0