From c0d38515d2f02ab893ae7f1e00efe2b7497e514c Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 20 Mar 2015 21:23:11 -0400 Subject: [PATCH] 2015: live: Misc cleanup. --- 2015/assets/js/stream.js | 54 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/2015/assets/js/stream.js b/2015/assets/js/stream.js index ce1dbd22..e9416066 100644 --- a/2015/assets/js/stream.js +++ b/2015/assets/js/stream.js @@ -81,7 +81,9 @@ app.mountToStreamUrl = function(mount) { }; app.changeVideoMount = function(video, mount) { - console.log(mount); + // This is quite hacky and doesn't feel like the Mithril way to do + // things, but we need to explicitly reload the video when the + // source URL changes. video.src = app.mountToStreamUrl(mount); video.load(); video.play(); @@ -107,26 +109,40 @@ app.streams = [ ]; app.controller = function() { - var self = this; - this.stream = m.prop(app.streams[0]); this.stats = m.prop(app.nullStats); - this.showDesktop = m.prop(false); - this.updateStats = function() { - self.stats = app.streamStats(self.stream().speakerMount); - }; + // Check stats every 10 seconds. + app.scheduleEvery(10000, this.updateStats.bind(this)); +}; - app.scheduleEvery(10000, function() { - self.updateStats(); - }); +app.controller.prototype.updateStats = function() { + this.stats = app.streamStats(this.stream().speakerMount); }; app.view = function(ctrl) { var stream = ctrl.stream(); - var showDesktop = ctrl.showDesktop(); var stats = ctrl.stats(); + var showDesktop = ctrl.showDesktop(); + + function renderSpeakerStream() { + return m("video.lp-video", { + id: "speaker-video", + controls: true, + autoplay: true + }, [ + m("source", { + src: app.mountToStreamUrl(stream.speakerMount) + }), + m("p", + m("em", [ + "Your browser does not support the HTML5 video tag, ", + m("a", { href: "TODO" }, "[ please download ]"), + "the video instead" + ])) + ]); + } function renderDesktopStream() { return m("video.lp-video", { @@ -203,21 +219,7 @@ app.view = function(ctrl) { renderRoomSelector(), m("h2", stream.name), renderStats(), - m("video.lp-video", { - id: "speaker-video", - controls: true, - autoplay: true - }, [ - m("source", { - src: app.mountToStreamUrl(stream.speakerMount) - }), - m("p", - m("em", [ - "Your browser does not support the HTML5 video tag, ", - m("a", { href: "TODO" }, "[ please download ]"), - "the video instead" - ])) - ]), + renderSpeakerStream(), showDesktop ? renderDesktopStream() : null, renderToggleDesktopStream(), m("h2", "IRC"), -- 2.25.1