<script src="<?php echo e(url('public/camera/DetectRTC.js')); ?>"></script>
<script src="<?php echo e(url('public/camera/EBML.js')); ?>"></script>
<script>
    let camera_first = "";
    let deviceId = 0;
    let countobs = 0;
    let tempobs1 = 0;
    let tempobs2 = 0;
    let windowsobs = false;
    DetectRTC.load(function() {
        let camera_source = 1;
        DetectRTC.videoInputDevices.forEach(function(device, idx) {
            if(device.label=="OBS Virtual Camera"){
                tempobs1 = device.deviceId;
            }
            if(device.label=="OBS Virtual Camera (Windows Virtual Camera)"){
                windowsobs = true;
                tempobs2 = device.deviceId;
            }
        });
        if(windowsobs){
            deviceId = tempobs2;
        }else{
            deviceId = tempobs1;
        }
    });

    DetectRTC.load(function() {
        navigator.getUserMedia({
                audio: false,
                video: {
                    deviceId: camera_first,
                    width: 1920,
                    height: 1080
                }
            },
            function(stream) {
                var video = document.querySelector('#video1');
                video.srcObject = stream;
                video.onloadedmetadata = function(e) {
                    video.play();
                };
                var mediaRecorder = new MediaRecorder(video.srcObject, {
                    mimeType: 'video/webm;codecs=vp9,opus',
                    bitsPerSecond: 5000000
                });
                var chunks = [];
            },
            function(err) {
                console.log("The following error occurred: " + err.name);
            }
        );
    });

    var video1 = document.getElementById('video1');
    // setTimeout(function() {
        var heightvdo1 = $('#video1').height();
        DetectRTC.load(function() {
            navigator.getUserMedia({
                    audio: false,
                    video: {
                        deviceId: deviceId,
                        width: 1920,
                        height: 1080
                    }
                },
                function(stream) {
                    var video = document.querySelector('#video1');
                    video.srcObject = stream;
                    video.onloadedmetadata = function(e) {
                        video.play();
                    };
                },
                function(err) {
                    console.log("The following error occurred: " + err.name);
                }
            );
        });
    // }, 1000);
</script>
<?php /**PATH D:\laragon\htdocs\screening\resources\views/endocapture/camera/obs/js_DetectRTC.blade.php ENDPATH**/ ?>