diff options
author | Minteck <contact@minteck.org> | 2022-05-18 18:50:12 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-05-18 18:50:12 +0200 |
commit | 0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0 (patch) | |
tree | 97a7e15187fe7fcb5b8775e03a62f62ac8fc5c61 /kartik/views/script/core_music.js | |
parent | d4805039b8ea7b30f5e78cf53caf8fd3f267256a (diff) | |
download | arcade-0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0.tar.gz arcade-0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0.tar.bz2 arcade-0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0.zip |
Diffstat (limited to 'kartik/views/script/core_music.js')
-rwxr-xr-x | kartik/views/script/core_music.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kartik/views/script/core_music.js b/kartik/views/script/core_music.js new file mode 100755 index 0000000..b35f5db --- /dev/null +++ b/kartik/views/script/core_music.js @@ -0,0 +1,35 @@ +if (location.hash === "#ready") { + global.musicElement = new Audio(); + + global.musicManager = { + setMusic: (args) => { + musicElement.src = args; + musicElement.play(); + musicElement.volume = 1; + musicElement.loop = true; + }, + fadeMusic: () => { + if (!musicElement.paused) { + csi1 = setInterval(() => { + if (musicElement.volume <= 0.3) { + clearInterval(csi1); + return; + } + musicElement.volume = musicElement.volume - 0.05; + }, 100) + } + }, + unfadeMusic: () => { + if (!musicElement.paused) { + csi1 = setInterval(() => { + if (musicElement.volume >= 0.95) { + clearInterval(csi1); + return; + } + musicElement.volume = musicElement.volume + 0.05; + }, 100) + } + } + } + +}
\ No newline at end of file |