diff --git a/web/libs/js/dash2.config.js b/web/libs/js/dash2.config.js index 76352beb..280a8693 100644 --- a/web/libs/js/dash2.config.js +++ b/web/libs/js/dash2.config.js @@ -97,8 +97,10 @@ $.ccio.form.details=function(e){ }); e.f.find('[name="details"]').val(JSON.stringify(e.ar)); }; +$('body').one('click',function(){ + window.hadFocus = true +}) $(document).ready(function(e){ - //check switch UI e.o=$.ccio.op().switches; if(e.o){ diff --git a/web/libs/js/dash2.elementbuilder.js b/web/libs/js/dash2.elementbuilder.js index 7bda74de..a158759b 100644 --- a/web/libs/js/dash2.elementbuilder.js +++ b/web/libs/js/dash2.elementbuilder.js @@ -303,15 +303,27 @@ $.ccio.tm=function(x,d,z,user){ el.muted = "muted" }) }else{ - $.each(monitorMutes,function(monitorId,choice){ - if(choice === 1){ + var hasFocus = $.ccio.windowFocus && hadFocus + $.each($.ccio.mon,function(frontId,monitor){ + setTimeout(() => { + var monitorId = monitor.mid + var muted = monitorMutes[monitorId] try{ var vidEl = $('.monitor_item[mid="' + monitorId + '"] video')[0] - vidEl.muted = true + if(vidEl.length === 0)return; + if(muted === 1){ + vidEl.muted = true + }else{ + if(hasFocus){ + vidEl.muted = false + }else{ + console.error('User must have window active to unmute.') + } + } }catch(err){ - + // console.log(err) } - } + },2000) }) } break; diff --git a/web/libs/js/dash2.elements.js b/web/libs/js/dash2.elements.js index b4492aa4..ed69bd51 100644 --- a/web/libs/js/dash2.elements.js +++ b/web/libs/js/dash2.elements.js @@ -258,7 +258,11 @@ $(document).ready(function(e){ vidEl.muted = true }else{ if(masterMute !== 1){ - vidEl.muted = false + if($.ccio.windowFocus && hadFocus){ + vidEl.muted = false + }else{ + console.error('User must have window active to unmute.') + } } } var volumeIcon = monitorMutes[monitorId] !== 1 ? 'volume-up' : 'volume-off'