From 98f88607a0361d1bc3e8722a737bb568baf15d10 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 20 Jun 2017 16:11:42 -0700 Subject: [PATCH] Remove recorder UI when we fail to 'getUserMedia' FREEBIE --- js/views/recorder_view.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/views/recorder_view.js b/js/views/recorder_view.js index 1405dd6ab..b4e419d37 100644 --- a/js/views/recorder_view.js +++ b/js/views/recorder_view.js @@ -34,7 +34,9 @@ if (this.interval) { clearInterval(this.interval); } - this.source.disconnect(); + if (this.source) { + this.source.disconnect(); + } if (this.context) { this.context.close().then(function() { console.log('audio context closed'); @@ -64,11 +66,12 @@ navigator.webkitGetUserMedia({ audio: true }, function(stream) { this.source = this.context.createMediaStreamSource(stream); this.source.connect(this.input); - }.bind(this), this.onError); + }.bind(this), this.onError.bind(this)); this.recorder.startRecording(); }, onError: function(error) { console.log(error); + this.close(); } }); })();