Search code examples
javascriptwebcammicrophone

Microphone access Microsoft Edge


I have next code which works good in Chrome:

<!DOCTYPE html>
    <a href="Default.html">Default.html</a>
    <head>
    <meta charset="utf-8"/>
    <title></title>
    <script type="text/javascript">
        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 whatever you want 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");
        }
    </script>
    </head>
    <body>
        <h2>Media Capture and Streaming</h2>
        <p>Let's stream our video!</p>
        <video autoplay></video>
    </body>
</html>

But I have problems with Edge because in every page refreshing Edge asks new "allow block microphone request". Is it possible to make it permanent in Edge like in Chrome? Because I know sites where this feature works permanently in Chrome and you don't need to allow access each time.


Solution

  • Using SSL(https) solved the problem.