From 25d260dccd1b8c049db4c4af8d07f588c36b31dd Mon Sep 17 00:00:00 2001 From: Trysdyn Black Date: Thu, 2 Jan 2025 08:31:56 -0800 Subject: [PATCH] Remember volume settings between streams This is same-session only. We still don't store any session data or cookies. We dump mute and volume settings to an object when a webcall stream is reaped, then restore them if the stream comes back. This should address hardship in a lossy connection or someone "quickly restarting OBS" needing to re-unmute the player. Closes #5 --- assets/player.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/assets/player.js b/assets/player.js index 8c1620f..60c2bf9 100644 --- a/assets/player.js +++ b/assets/player.js @@ -7,6 +7,7 @@ xhr.onreadystatechange = function() { } disabledPlayers = []; +playerVolumeSettings = {}; // Auto-resize frames in a webcall interface function webcallFrameResize() { @@ -146,8 +147,12 @@ function closePlayer(containerId) { } function destroyPlayerById(containerId) { - // Tear down player player = OvenPlayer.getPlayerByContainerId(containerId); + + // Get our volume settings to save for re-use if this player comes back + playerVolumeSettings[containerId] = [player.getMute(), player.getVolume()]; + + // Tear down player player.remove(); // Delete frame @@ -171,7 +176,16 @@ function processStreamList(streams) { // Create any player in the list that doesn't have one streams.forEach((i, index) => { if (OvenPlayer.getPlayerByContainerId(i) == null) { - createPlayer(i, true, 100); + // Check if we have volume settings for this player + var muted = true; + var volume = 100; + if (i in playerVolumeSettings) { + muted = playerVolumeSettings[i][0]; + volume = playerVolumeSettings[i][1]; + } + + // Create the player with noted settings or defaults + createPlayer(i, muted, volume); } })