I\'m new to Angular 2.
If I have a video tag, like :
And a javas
In your template you can include the video directive like this:
then in your component:
@ViewChild('video') video:any;
// note that "#video" is the name of the template variable in the video element
ngAfterViewInit() {
let _video=this.video.nativeElement;
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true })
.then(stream => {
_video.src = window.URL.createObjectURL(stream);
_video.play();
})
}
}
see this on stackblitz: https://stackblitz.com/edit/live-video