diff options
author | Minteck <nekostarfan@gmail.com> | 2021-06-05 19:27:48 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-06-05 19:27:48 +0200 |
commit | 8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6 (patch) | |
tree | 7096b67b189c0220826123c7d5b121752545d140 /views/script/core_music.js | |
download | kartik-client-8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6.tar.gz kartik-client-8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6.tar.bz2 kartik-client-8cf5cefe6e91a5a1ed6eeaae4d94760d84c304a6.zip |
Presque sortie du jeu
Diffstat (limited to 'views/script/core_music.js')
-rw-r--r-- | views/script/core_music.js | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/views/script/core_music.js b/views/script/core_music.js new file mode 100644 index 0000000..d1e8619 --- /dev/null +++ b/views/script/core_music.js @@ -0,0 +1,109 @@ +global.csng = null; +global.csp1 = null; +global.csp2 = null; +global.cspn = 1; +const musicIpc = require('electron').ipcRenderer; + +musicIpc.on('setmusic', (event, args) => { + song = args; + + if (song !== null && song !== "" && csng !== song) { + if (cspn === 1) { + if (csp1 !== null) { + csi1 = setInterval(() => { + if (csp1.volume <= 0.05) { + csp1.pause(); + clearInterval(csi1); + return; + } + csp1.volume = csp1.volume - 0.05; + }, 100) + } + csp2 = new Audio(song); + csp2.volume = 0; + csp2.loop = true; + csp2.play(); + csi2 = setInterval(() => { + if (csp2.volume >= 0.95) { + clearInterval(csi2); + return; + } + csp2.volume = csp2.volume + 0.05; + }, 100) + csng = song; + cspn = 2; + } else { + if (csp2 !== null) { + csi2 = setInterval(() => { + if (csp2.volume <= 0.05) { + csp2.pause(); + clearInterval(csi2); + return; + } + csp2.volume = csp2.volume - 0.05; + }, 100) + } + csp1 = new Audio(song); + csp1.volume = 0; + csp1.loop = true; + csp1.play(); + csi1 = setInterval(() => { + if (csp1.volume >= 0.95) { + clearInterval(csi1); + return; + } + csp1.volume = csp1.volume + 0.05; + }, 100) + csng = song; + cspn = 1; + } + } +}) + +musicIpc.on('fademusic', (event) => { + if (cspn === 1) { + if (csp1 !== null) { + csi1 = setInterval(() => { + if (csp1.volume <= 0.5) { + clearInterval(csi1); + return; + } + csp1.volume = csp1.volume - 0.05; + }, 100) + } + } else { + if (csp2 !== null) { + csi2 = setInterval(() => { + if (csp2.volume <= 0.5) { + clearInterval(csi2); + return; + } + csp2.volume = csp2.volume - 0.05; + }, 100) + } + } +}) + +musicIpc.on('unfademusic', (event) => { + if (cspn === 1) { + if (csp1 !== null) { + csi1 = setInterval(() => { + if (csp1.volume >= 0.95) { + clearInterval(csi1); + return; + } + csp1.volume = csp1.volume + 0.05; + }, 100) + } + } else { + if (csp2 !== null) { + csi2 = setInterval(() => { + if (csp2.volume >= 0.95) { + clearInterval(csi2); + return; + } + csp2.volume = csp2.volume + 0.05; + }, 100) + } + } +})
\ No newline at end of file |