diff options
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/webAO/client.js b/webAO/client.js index f91d208..eb27979 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -444,7 +444,7 @@ class Client extends EventEmitter { document.querySelector('#client_chatboxselect [value="' + cookiechatbox + '"]').selected = true; setChatbox(cookiechatbox); - document.getElementById("client_musicaudio").volume = getCookie("musicVolume") || 1; + document.getElementById("client_mvolume").value = getCookie("musicVolume") || 1; changeMusicVolume(); document.getElementById("client_sfxaudio").volume = getCookie("sfxVolume") || 1; changeSFXVolume(); @@ -734,8 +734,11 @@ class Client extends EventEmitter { handleMC(args) { const track = prepChat(args[1]); let charID = Number(args[2]); + const showname = args[3] ? args[3] : ""; + const looping = args[4] ? Boolean(args[4]) : false; + const channel = args[5] ? Number(args[5]) : 0; - const music = viewport.music; + const music = viewport.music[channel]; let musicname; music.pause(); if(track.startsWith("http")) { @@ -743,6 +746,7 @@ class Client extends EventEmitter { } else { music.src = MUSIC_HOST + encodeURI(track.toLowerCase()); } + music.loop = looping; music.play(); try { @@ -1486,8 +1490,9 @@ class Viewport { this.testimonyAudio = document.getElementById("client_testimonyaudio"); this.testimonyAudio.src = `${AO_HOST}sounds/general/sfx-guilty.wav`; - this.music = document.getElementById("client_musicaudio"); - this.music.src = `${AO_HOST}sounds/music/trial (aa).mp3`; + this.music = new Array(3); + this.music.fill(new Audio(`${AO_HOST}sounds/music/trial (aa).mp3`)) + .forEach(channel => channel.volume = 0.5); this.updater = null; this.testimonyUpdater = null; @@ -1513,7 +1518,7 @@ class Viewport { } /** - * Sets the volume of the blip sound. + * Sets the volume of the blip sounds. * @param {number} volume */ set blipVolume(volume) { @@ -1521,6 +1526,14 @@ class Viewport { } /** + * Sets the volume of the music. + * @param {number} volume + */ + set musicVolume(volume) { + this.music.forEach(channel => channel.volume = volume); + } + + /** * Returns the path which the background is located in. */ get bgFolder() { @@ -2345,7 +2358,8 @@ window.area_click = area_click; * Triggered by the music volume slider. */ export function changeMusicVolume() { - setCookie("musicVolume", document.getElementById("client_musicaudio").volume); + viewport.musicVolume = document.getElementById("client_mvolume").value; + setCookie("musicVolume", document.getElementById("client_mvolume").value); } window.changeMusicVolume = changeMusicVolume; |
