From: David Thompson Date: Sat, 21 Mar 2015 01:23:11 +0000 (-0400) Subject: 2015: live: Misc cleanup. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c0d38515d2f02ab893ae7f1e00efe2b7497e514c;p=libreplanet-static.git 2015: live: Misc cleanup. --- 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"),