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.');
}