From aa864e01d011e42f3f1006f2f6ae3387653bd136 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 29 Sep 2015 12:50:01 -0500 Subject: [PATCH] fix: webcam no longer throws if no frames are recorded --- ui/lib/com/webcam-giffer-form.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ui/lib/com/webcam-giffer-form.js b/ui/lib/com/webcam-giffer-form.js index 1f853c8..2012bb6 100644 --- a/ui/lib/com/webcam-giffer-form.js +++ b/ui/lib/com/webcam-giffer-form.js @@ -241,17 +241,23 @@ module.exports = function (rootMsg, branchMsg, opts) { // stop capture clearInterval(recordInterval) - // show output stream - invideo.classList.add('hide') - outvideo.classList.remove('hide') - // remove 'recording' border invideo.classList.remove('recording') // produce output - blob = encoder.compile() - console.log('Webm video encoded:', blob.size, 'bytes') - outvideo.src = URL.createObjectURL(blob, 'video/webm') + if (encoder.frames && encoder.frames.length) { + blob = encoder.compile() + console.log('Webm video encoded:', blob.size, 'bytes') + outvideo.src = URL.createObjectURL(blob, 'video/webm') + + // show output stream + invideo.classList.add('hide') + outvideo.classList.remove('hide') + } else { + // show input stream + invideo.classList.remove('hide') + outvideo.classList.add('hide') + } enable() }