From: David Thompson Date: Sat, 21 Mar 2015 01:38:57 +0000 (-0400) Subject: 2015: live: Crudely sync play/paused state with both videos. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d5a3bb68101e943d3905dbb162a46dd073616f6c;p=libreplanet-static.git 2015: live: Crudely sync play/paused state with both videos. --- diff --git a/2015/assets/js/stream.js b/2015/assets/js/stream.js index b3f63d76..31fc34b9 100644 --- a/2015/assets/js/stream.js +++ b/2015/assets/js/stream.js @@ -89,6 +89,16 @@ app.changeVideoMount = function(video, mount) { video.play(); }; +app.withVideo = function(id, callback) { + return function() { + var video = document.getElementById(id); + + if(video) { + callback(video); + } + }; +}; + app.streams = [ { name: "Room 123", @@ -130,7 +140,14 @@ app.view = function(ctrl) { return m("video.lp-video", { id: "speaker-video", controls: true, - autoplay: true + autoplay: true, + // Sync desktop stream state as best we can. + onpause: app.withVideo("desktop-video", function(video) { + video.pause(); + }), + onplay: app.withVideo("desktop-video", function(video) { + video.play(); + }) }, [ m("source", { src: app.mountToStreamUrl(stream.speakerMount)