Fix audio auto-starting on montage. AUdio should never auto-start... Or maybe we need to track it in cookies, but by default should start muted

This commit is contained in:
Isaac Connor
2025-11-21 22:33:22 -05:00
parent 04a508500f
commit f796fa913f
2 changed files with 22 additions and 13 deletions

View File

@@ -199,7 +199,7 @@ function MonitorStream(monitorData) {
console.log('No stream in setScale');
return;
}
console.trace("setScale", stream, newscale, width, height, param);
//console.trace("setScale", stream, newscale, width, height, param);
if (height == '0px') {
console.error("Don't want to set 0px height. Reverting to auto");
height = 'auto';
@@ -348,7 +348,7 @@ function MonitorStream(monitorData) {
}
this.streamListenerBind = streamListener.bind(null, this);
console.log('start go2rtcenabled:', this.Go2RTCEnabled, 'this.player:', this.player, 'muted', this.muted);
//console.log('start go2rtcenabled:', this.Go2RTCEnabled, 'this.player:', this.player, 'muted', this.muted);
$j('#volumeControls').hide();
@@ -361,7 +361,7 @@ function MonitorStream(monitorData) {
stream.id = old_stream.id; // should be liveStream+id
stream.style = old_stream.style; // Copy any applied styles
stream.background = true; // We do not use the document hiding/showing analysis from "video-rtc.js", because we have our own analysis
stream.setAttribute("muted", this.muted);
stream.muted = this.muted;
const Go2RTCModUrl = url;
const webrtcUrl = Go2RTCModUrl;
this.currentChannelStream = (streamChannel == 'default') ? ((this.RTSP2WebStream == 'Secondary') ? 1 : 0) : streamChannel;
@@ -520,9 +520,11 @@ function MonitorStream(monitorData) {
stream.onerror = this.img_onerror.bind(this);
stream.onload = this.img_onload.bind(this);
if (this.activePlayer == 'zms') {
// Only if we were already zms streaming
this.streamCmdTimer = setInterval(this.streamCmdQuery.bind(this), statusRefreshTimeout);
this.streamCommand(CMD_PLAY);
} else if (-1 != stream.src.indexOf('mode=paused')) {
// Initial page load has zms with mode=paused
this.streamCmdTimer = setInterval(this.streamCmdQuery.bind(this), statusRefreshTimeout);
this.streamCommand(CMD_PLAY);
} else {
@@ -541,8 +543,8 @@ function MonitorStream(monitorData) {
if (-1 == src.search('mode=')) {
src += '&mode=jpeg';
}
console.log("Setting src.src", stream.src, src);
if (stream.src != src) {
//console.log("Setting src.src", stream.src, src);
stream.src = '';
stream.src = src;
}
@@ -921,23 +923,29 @@ function MonitorStream(monitorData) {
* mode: switch, on, off
*/
this.controlMute = function(mode = 'switch') {
const mid = this.id;
const volumeSlider = this.getVolumeSlider(mid);
const audioStream = this.getAudioStream(mid);
const iconMute = this.getIconMute(mid);
if (!iconMute) return;
if (mode=='switch') {
this.muted = !this.muted;
} else if (mode=='on') {
this.muted = false;
} else if (mode=='off') {
this.muted = true;
} else if (mode=='off') {
this.muted = false;
} else {
console.log("Invalid value for mode", mode);
}
const mid = this.id;
const audioStream = this.getAudioStream(mid);
if (audioStream) {
audioStream.muted = this.muted;
console.log("Setting muted for ", mid, " to ", this.muted, "stream value is", audioStream.muted);
} else {
console.log("No audiostream! in controlMute");
}
const iconMute = this.getIconMute(mid);
if (!iconMute) return;
const volumeSlider = this.getVolumeSlider(mid);
if (audioStream) audioStream.muted = this.muted;
if (!this.muted) {
iconMute.innerHTML = 'volume_up';
volumeSlider.classList.add('noUi-mute');

View File

@@ -244,6 +244,7 @@ export class VideoRTC extends HTMLElement {
this.video.style.display = 'block'; // fix bottom margin 4px
this.video.style.width = '100%';
this.video.style.height = '100%';
this.video.muted = this.muted;
this.appendChild(this.video);