Created
July 13, 2021 16:54
-
-
Save hamzamu/40039745e27ec950aba60b19a705f0a1 to your computer and use it in GitHub Desktop.
Meteor: Webcam access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>meteor-exp</title> | |
</head> | |
<body> | |
{{> camera}} | |
</body> | |
<template name="camera"> | |
<video id="video" width="800" height="600" | |
autoplay></video> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Template } from 'meteor/templating'; | |
import './main.html'; | |
Template.camera.onRendered(function () { | |
navigator.mediaDevices.getUserMedia({ | |
video: true, | |
audio: true | |
}) | |
.then(function (stream) { | |
video.srcObject = stream | |
console.log({stream}) | |
}) | |
.catch(e => console.log(e.name + ": " + e.message)); | |
var video = document.getElementById('video'); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment