Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
iniciarCamera() {
let nav = <any>navigator;
nav.getUserMedia = nav.getUserMedia || nav.mozGetUserMedia || nav.webkitGetUserMedia;
if (!nav.getUserMedia) {
UiSnackbar.show({
text: 'Seu navegador não tem suporte para Webcam'
});
return;
}
let options = {
video: true,
audio: false
};
nav.getUserMedia(options, (stream) => {
let webcamUrl = URL.createObjectURL(stream);
this.videoSrc = this.sanitizer.bypassSecurityTrustUrl(webcamUrl);
let video = this.element.nativeElement.querySelector('#video-user');
video.autoplay = true;
let reconhecimento = this;
let getVideoSize = function() {
reconhecimento.videoWidth = video.videoWidth;
reconhecimento.videoHeight = video.videoHeight;
video.removeEventListener('playing', getVideoSize, false);
};
video.addEventListener('playing', getVideoSize, false);
}, (err) => {
UiSnackbar.show({
text: 'Ocorreu um erro ao iniciar a Webcam'
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.