update monitor muting for modern browsers

must interfact with web page before audio can automatically be unmuted
mitchross-coral-installer-update
Moe Alam 2020-12-01 07:25:25 -08:00
parent 48ce8125ab
commit 55cec40869
3 changed files with 25 additions and 7 deletions

View File

@ -97,8 +97,10 @@ $.ccio.form.details=function(e){
}); });
e.f.find('[name="details"]').val(JSON.stringify(e.ar)); e.f.find('[name="details"]').val(JSON.stringify(e.ar));
}; };
$('body').one('click',function(){
window.hadFocus = true
})
$(document).ready(function(e){ $(document).ready(function(e){
//check switch UI //check switch UI
e.o=$.ccio.op().switches; e.o=$.ccio.op().switches;
if(e.o){ if(e.o){

View File

@ -303,15 +303,27 @@ $.ccio.tm=function(x,d,z,user){
el.muted = "muted" el.muted = "muted"
}) })
}else{ }else{
$.each(monitorMutes,function(monitorId,choice){ var hasFocus = $.ccio.windowFocus && hadFocus
if(choice === 1){ $.each($.ccio.mon,function(frontId,monitor){
setTimeout(() => {
var monitorId = monitor.mid
var muted = monitorMutes[monitorId]
try{ try{
var vidEl = $('.monitor_item[mid="' + monitorId + '"] video')[0] var vidEl = $('.monitor_item[mid="' + monitorId + '"] video')[0]
if(vidEl.length === 0)return;
if(muted === 1){
vidEl.muted = true vidEl.muted = true
}else{
if(hasFocus){
vidEl.muted = false
}else{
console.error('User must have window active to unmute.')
}
}
}catch(err){ }catch(err){
// console.log(err)
}
} }
},2000)
}) })
} }
break; break;

View File

@ -258,7 +258,11 @@ $(document).ready(function(e){
vidEl.muted = true vidEl.muted = true
}else{ }else{
if(masterMute !== 1){ if(masterMute !== 1){
if($.ccio.windowFocus && hadFocus){
vidEl.muted = false vidEl.muted = false
}else{
console.error('User must have window active to unmute.')
}
} }
} }
var volumeIcon = monitorMutes[monitorId] !== 1 ? 'volume-up' : 'volume-off' var volumeIcon = monitorMutes[monitorId] !== 1 ? 'volume-up' : 'volume-off'