From 2d36ad921b4e9db218346f84bd839561b48f7307 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 30 May 2014 13:59:51 +0200 Subject: [PATCH] Pause a preview when going on the main div This reduce the CPU pressure, as only one stream needs to be decoded Also prevent the main vid to double its audio level (which was not a bad thing, but was just beacause this same track was decoded and played twice, it'd be better to play with the volume of only one track) Doesn't work well on FF for now (because FF doesn't like switching main div, it often do not resume the video, or after several seconds, will need to investigate) --- public/js/vroom.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/js/vroom.js b/public/js/vroom.js index eb19035..93bd627 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -356,6 +356,15 @@ function initVroom(room) { if ($('#mainVideo').html() != ''){ $('#mainVideo').hide(200); wait = 200; + // Play all preview + // the one in the mainVid was paused, with a reduced opacity + // This isn't working on FF for the moment + if ($.browser.webkit){ + $('#webRTCVideo video').each(function(){ + $(this)[0].play(); + $(this).css('opacity', '1'); + }); + } } setTimeout(function(){ $('#mainVideo').html(''); @@ -376,6 +385,15 @@ function initVroom(room) { $('.selected').removeClass('selected'); el.addClass('selected'); mainVid = el.attr('id'); + // Pause the corresponding preview + // and reduce opacity + if ($.browser.webkit){ + $('#webRTCVideo video').each(function(){ + $(this)[0].play(); + }); + el[0].pause(); + el.css('opacity', '.3'); + } $('#mainVideo').show(200); } }, wait);