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>
8
  • 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, 2016 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. Feb 22, 2016 at 11:59
  • Then you need to provide more details.
    – Adrian Ber
    Feb 22, 2016 at 12:32
  • OK I will write the code... Feb 22, 2016 at 12:35
  • 3
    Are you using https?
    – jib
    Feb 22, 2016 at 19:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.