Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.
Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin. Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Javascriptda vebkameradan olingan tasvirni mijozga yuborish

0 ovoz
70 marta ko‘rilgan
so‘radi 04 yanvar Farruxnet (1,406 bal)

Veb kamiradan javascript orqali video tasvir olindi

main.js

 window.addEventListener("DOMContentLoaded", function() {             
                    var canvas = document.getElementById('canvas');
                    var context = canvas.getContext('2d');
                    var video = document.getElementById('video');
                    var mediaConfig =  { video: true };
                    var errBack = function(e) {
                        console.log('Xato', e)
                    };
                 
                    if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
                        navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
                            video.srcObject = stream;
                            video.play();
                        });
                    }
    
                    else if(navigator.getUserMedia) {
                        navigator.getUserMedia(mediaConfig, function(stream) {
                            video.src = stream;
                            video.play();
                        }, errBack);
                    } else if(navigator.webkitGetUserMedia) {
                        navigator.webkitGetUserMedia(mediaConfig, function(stream){
                            video.src = window.webkitURL.createObjectURL(stream);
                            video.play();
                        }, errBack);
                    } else if(navigator.mozGetUserMedia) {
                        navigator.mozGetUserMedia(mediaConfig, function(stream){
                            video.src = window.URL.createObjectURL(stream);
                            video.play();
                        }, errBack);
                    }         
                }, false);

Olingan tasvir shu sahifani o'zida chop qilinyapdi!

index.html

<!DOCTYPE html>
<html>
<head>
    <title>Web Stream</title>
</head>
<body>
        <video id="video" autoplay="autoplay" width="640" height="480"></video>
        <canvas id="canvas" width="640" height="480"></canvas>  
    <script src='main.js'></script>
</body>
</html>

Shu olingan tasvirni qanday clientga yuborsa bo'ladi!

client.html

<!DOCTYPE html>
<html>
<head>
    <title>Client Page</title>  
</head>
<body>
       <video id="video" autoplay="autoplay" width="640" height="480"></video>
        <canvas id="canvas" width="640" height="480"></canvas>   
    <script src='main.js'></script>
</body>
</html>

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...