From 39648e1b2fcb700b12e63f86a3fffb6091b954ec Mon Sep 17 00:00:00 2001 From: Brian Perry Date: Sat, 20 Apr 2019 12:55:41 -0500 Subject: [PATCH] Live camera prototype --- css/live-camera.css | 5 +++++ index.html | 4 ++++ js/live-camera.js | 13 +++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 css/live-camera.css create mode 100644 js/live-camera.js diff --git a/css/live-camera.css b/css/live-camera.css new file mode 100644 index 0000000..b67af5d --- /dev/null +++ b/css/live-camera.css @@ -0,0 +1,5 @@ +video { + position: absolute; + left: 0; + bottom: 0; +} \ No newline at end of file diff --git a/index.html b/index.html index a63853e..04cb1e9 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,7 @@ + @@ -31,8 +32,11 @@

HTML5 Live Captioning

+ + + diff --git a/js/live-camera.js b/js/live-camera.js new file mode 100644 index 0000000..6710b6d --- /dev/null +++ b/js/live-camera.js @@ -0,0 +1,13 @@ +/* Based on https://davidwalsh.name/browser-camera */ + +// Grab elements, create settings, etc. +var video = document.getElementById('video'); + +// Get access to the camera! +if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { + // Not adding `{ audio: true }` since we only want video now + navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) { + video.srcObject = stream; + video.play(); + }); +} \ No newline at end of file