0

I need to use canvas camera capture jQuery in my C# ASP.NET Core MVC app.

If I run it in Visual Studio Code, it runs fine. But if I publish it to my IIS Server and call by IP address, the same page returns.

Your browser does not support the WebRTC API

This is my Webcam.js

const video = document.getElementById('webcamVideo');
const canvas = document.getElementById('snapshotCanvas');
const captureButton = document.getElementById('captureButton');

function onStreaming(stream) {
    video.srcObject = stream;
}

function onError(error) {
    console.error('Error accessing the webcam:', error);
}

function captureImage() {
    const context = canvas.getContext('2d');
    context.drawImage(video, 0, 0, canvas.width, canvas.height);
}

//captureButton.addEventListener('click', captureImage);

if ('mediaDevices' in navigator && 'getUserMedia' in navigator.mediaDevices) {
    navigator.mediaDevices.getUserMedia({ video: true })
        .then(onStreaming)
        .catch(onError);
} else {
    alert('Your browser does not support the WebRTC API.');
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Are you using https? [*Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.*](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/mediaDevices) – rene May 19 '23 at 03:59
  • my own server not using https. Is it have another way to fix it? – Ratchanon Volty May 19 '23 at 04:03
  • I doubt it. Maybe some browser allows you to disable the check. Better generate a selfsigned certificate and configure that on IIS. See https://aboutssl.org/how-to-create-a-self-signed-certificate-in-iis/ and https://superuser.com/search?q=+selfsigned+ – rene May 19 '23 at 04:23
  • Try it. But it doesn't work. Please help me. – Ratchanon Volty May 19 '23 at 06:39
  • can [this answer](https://stackoverflow.com/a/43088374) help you? – Tiny Wang May 19 '23 at 07:29

0 Answers0