Trying to access IP Camera that is connected to a wifi.
I am connected to that wifi but I am getting error. If I try open using vlc I am able to connect but not getUserMedia has null.
@Component({ selector: 'app-home', templateUrl: './home.component.html', }) export class HomeComponent { @ViewChild('video') video: any; constructor() { } hasGetUserMedia() { return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia); } ngAfterViewInit() { if (this.hasGetUserMedia()) { // Good to go! console.log("Gooddd................"); } else { alert('getUserMedia() is not supported by your browser'); } let _video = this.video.nativeElement; if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { navigator.mediaDevices.getUserMedia({ video: true, audio: true }) .then(function (stream) { _video.src = window.URL.createObjectURL(stream); _video.play(); }).catch(function (err) { console.log(err); }); } } } <video #video width="640" height="480" autoplay></video> 16 Answers
This happens when you dont have any device to capture video or capture audio
try checking if your webcam and your microphone are working fine
try changing this line:
_video.src = window.URL.createObjectURL(stream); with this one:
_video.srcObject = stream; Try without "audio: true". Its help for my. (Microphone are not work). And check webcam on other sites. Maybe need check permissions for this page.
In my case i have connected external camera through USB i was able to get the devices, i was getting kind of devices as audiooutput and videoinput, and there was no audioinput(microphone device) but while i was requesting for devices i passed constraints as..
function Webcam(){ this.constraints = { video: true, audio: true } this.userMedia = null; this.mediaDevices = navigator.mediaDevices; this.initialize = function(){ this.userMedia = this.mediaDevices.getUserMedia(this.constraints); } } let webcam = new Webcam(); webcam.initialize(); So Promise not satisified and getting error as Requested device not found.
Use this line to initialize the webcam and microphone:
navigator.mediaDevices.getUserMedia({ audio: true, video: true }); Try attaching an earpiece or earplug with microphone to your PC. mine has no microphone that was why I got that error
1