JSFiddle - React, Tailwind, and code Playground

by Rami Sarieddine

HTML

<h2>Media Capture and Streaming</h2>
    <p>Let's stream our video!</p>
    <video autoplay></video>

JavaScript

navigator.getUserMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);

if (navigator.getUserMedia) {
            navigator.getUserMedia(
            // constraints
            {
                video: true,
                audio: true
            },
            // successCallback
            function (localMediaStream) {
                var video = document.querySelector('video');
                video.src = window.URL.createObjectURL(localMediaStream);
                // Do something with the video
                video.play();
            },
                     // errorCallback
                     function (err) {
                         console.log("The following error occured: " + err);
                     });
        } else {
            alert("getUserMedia not supported by your web browser or Operating system version");
        }