2015: live: Crudely sync play/paused state with both videos.
authorDavid Thompson <dthompson2@worcester.edu>
Sat, 21 Mar 2015 01:38:57 +0000 (21:38 -0400)
committerDavid Thompson <dthompson2@worcester.edu>
Sat, 21 Mar 2015 01:38:57 +0000 (21:38 -0400)
2015/assets/js/stream.js

index b3f63d76855dad20a7c6a70df14f4b3ce6f2a7b2..31fc34b99532d4675d8f98cdf93ed53bd0f902b8 100644 (file)
@@ -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)