From b478bb92c0de5d3a10339b8a8fa861084bca4005 Mon Sep 17 00:00:00 2001 From: Moe Date: Sat, 4 Apr 2020 16:59:18 -0700 Subject: [PATCH] Mute Audio on Monitors individually (dashboard UI) --- web/libs/js/dash2.elementbuilder.js | 15 ++++++ web/libs/js/dash2.elements.js | 76 ++++++++++++++++++----------- 2 files changed, 63 insertions(+), 28 deletions(-) diff --git a/web/libs/js/dash2.elementbuilder.js b/web/libs/js/dash2.elementbuilder.js index 248cc702..02598017 100644 --- a/web/libs/js/dash2.elementbuilder.js +++ b/web/libs/js/dash2.elementbuilder.js @@ -77,6 +77,7 @@ $.ccio.tm=function(x,d,z,user){ delete(d.src); break; case 2://monitor stream + var monitorMutes = $.ccio.op().monitorMutes || {} try{k.d=JSON.parse(d.details);}catch(er){k.d=d.details;} k.mode=$.ccio.init('humanReadMode',d.mode); var dataTarget = '.monitor_item[mid=\''+d.mid+'\'][ke=\''+d.ke+'\'][auth=\''+user.auth_token+'\']'; @@ -93,6 +94,12 @@ $.ccio.tm=function(x,d,z,user){ tmp+=''; tmp+='
'//start of btn list var buttons = { + "Mute Audio": { + "label": lang['Mute Audio'], + "attr": "system=\"monitorMuteAudioSingle\" mid=\"" + d.mid + "\"", + "class": "primary", + "icon": monitorMutes[d.mid] !== 1 ? 'volume-up' : 'volume-off' + }, "Snapshot": { "label": lang['Snapshot'], "attr": "monitor=\"snapshot\"", @@ -266,10 +273,18 @@ $.ccio.tm=function(x,d,z,user){ } } k.e.append(tmp).find('.stream-element').resize(); + var monitorMutes = $.ccio.op().monitorMutes || {} if($.ccio.op().switches.monitorMuteAudio === 1){ k.e.find('video').each(function(n,el){ el.muted = "muted" }) + }else{ + $.each(monitorMutes,function(monitorId,choice){ + if(choice === 1){ + var vidEl = $('.monitor_item[mid="' + monitorId + '"] video')[0] + vidEl.muted = true + } + }) } break; case'user-row': diff --git a/web/libs/js/dash2.elements.js b/web/libs/js/dash2.elements.js index b950e070..849f618e 100644 --- a/web/libs/js/dash2.elements.js +++ b/web/libs/js/dash2.elements.js @@ -221,50 +221,70 @@ $(document).ready(function(e){ e.value = e.e.val() $.ccio.op(e.localStorage,e.value) }) - .on('click','[system]',function(e){ - var e={}; - e.e=$(this), - e.a=e.e.attr('system');//the function - switch(e.a){ - case'switch': - e.switch=e.e.attr('switch'); - e.o=$.ccio.op().switches - if(!e.o){ - e.o={} - } - if(!e.o[e.switch]){ - e.o[e.switch]=0 - } - if(e.o[e.switch]===1){ - e.o[e.switch]=0 + .on('click','[system]',function(){ + var e = {}; + var el = $(this) + switch(el.attr('system')){ + case'monitorMuteAudioSingle': + var monitorId = el.attr('mid') + var masterMute = $.ccio.op().switches.monitorMuteAudio + var monitorMutes = $.ccio.op().monitorMutes || {} + monitorMutes[monitorId] = monitorMutes[monitorId] === 1 ? 0 : 1 + $.ccio.op('monitorMutes',monitorMutes) + var vidEl = $('.monitor_item[mid="' + monitorId + '"] video')[0] + if(monitorMutes[monitorId] === 1){ + vidEl.muted = true }else{ - e.o[e.switch]=1 + if(masterMute !== 1){ + vidEl.muted = false + } } - $.ccio.op('switches',e.o) - switch(e.switch){ + var volumeIcon = monitorMutes[monitorId] !== 1 ? 'volume-up' : 'volume-off' + $(this).find('i').removeClass('fa-volume-up fa-volume-off').addClass('fa-' + volumeIcon) + break; + case'switch': + var systemSwitch = el.attr('switch'); + var theSwitches = $.ccio.op().switches + if(!theSwitches){ + theSwitches={} + } + if(!theSwitches[systemSwitch]){ + theSwitches[systemSwitch]=0 + } + if(theSwitches[systemSwitch]===1){ + theSwitches[systemSwitch]=0 + }else{ + theSwitches[systemSwitch]=1 + } + $.ccio.op('switches',theSwitches) + switch(systemSwitch){ case'monitorOrder': - if(e.o[e.switch] !== 1){ + if(theSwitches[systemSwitch] !== 1){ $('.monitor_item').attr('data-gs-auto-position','yes') }else{ $('.monitor_item').attr('data-gs-auto-position','no') } break; case'monitorMuteAudio': - $('.monitor_item video').each(function(n,el){ - if(e.o[e.switch] === 1){ - el.muted = true + var monitorMutes = $.ccio.op().monitorMutes || {} + $('.monitor_item video').each(function(n,vidEl){ + var monitorId = $(this).parents('[mid]').attr('mid') + if(theSwitches[systemSwitch] === 1){ + vidEl.muted = true }else{ - el.muted = false + if(monitorMutes[monitorId] !== 1){ + vidEl.muted = false + } } }) break; } - switch(e.e.attr('type')){ + switch(el.attr('type')){ case'text': - if(e.o[e.switch]===1){ - e.e.addClass('text-success') + if(theSwitches[systemSwitch]===1){ + el.addClass('text-success') }else{ - e.e.removeClass('text-success') + el.removeClass('text-success') } break; }