diff --git a/js/live.js b/js/live.js index 60d9e0d..d100bc4 100644 --- a/js/live.js +++ b/js/live.js @@ -35,6 +35,12 @@ function update_globals() { change_scientist(); } +// Change embed volume as slider is... slid +function update_volume() { + vol = document.getElementById('vol_slider').value; + embeds.forEach(e => e.setVolume(vol / 100)); +} + // Update individual textual elements in the overlay function change_game_name() { game_name = document.getElementById('gamename_text').value; @@ -49,7 +55,10 @@ function change_scientist() { } function update_embed(embed_num) { + // Switch channel change_embed_channel(embed_num); + + // Update our text fields n = document.getElementById('rat' + embed_num + 'name'); p = document.getElementById('rat' + embed_num + 'pronouns'); @@ -69,6 +78,7 @@ function change_embed_channel(embed_num) { e.style.display = 'block'; embeds[embed_num].setChannel(channel_name); + update_volume(); embeds[embed_num].play(); } @@ -94,6 +104,10 @@ function focus_audio(embed_num) { embeds.forEach(e => e.setMuted(true)); embeds[embed_num].setMuted(false); + // Fire a volume set just to be sure our volume is synced + // Embeds that are muted or disabled sometimes don't set volume + update_volume(); + speakers = document.querySelectorAll('.ratspeaker'); speakers.forEach(e => e.style.display = 'none'); @@ -153,8 +167,8 @@ function setup() { parent: ['voidfox.com'] })); - // Try to start volume at a known level - embeds.forEach(e => e.setVolume(1.0)); + // Set up volume slider handler + document.getElementById('vol_slider').oninput = update_volume } document.addEventListener('DOMContentLoaded', setup); diff --git a/live.html b/live.html index 741b92a..a7cd59a 100644 --- a/live.html +++ b/live.html @@ -38,7 +38,9 @@ Overlay: - + + Volume: +