Attempting to access an IP Camera that is connected to a WiFi network.
Even though I am connected to the same WiFi, I keep encountering an error. Strangely, I can connect using VLC, but getUserMedia returns 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()) {
// Ready to roll!
console.log("All good................");
} 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>