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
This commit is contained in:
Trysdyn Black 2025-01-02 08:31:56 -08:00
parent bc79be8a96
commit 25d260dccd

View file

@ -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);
}
})