Musik bugfixes

This commit is contained in:
silas 2018-10-10 19:27:59 +02:00
parent 7be46f60bb
commit 05188e37fd
3 changed files with 10 additions and 8 deletions

View File

@ -4938,7 +4938,7 @@ class AudioChain {
await this.chainFunction(source); await this.chainFunction(source);
source.start(delay, offset, duration); source.start(delay, offset, duration);
this.startTime = (new Date()).getTime(); this.startTime = (new Date()).getTime() - (Helper.nonNull(offset, 0) * 1000);
this.source = source; this.source = source;
this.running = true; this.running = true;
} }
@ -4946,13 +4946,14 @@ class AudioChain {
async stop(delay) { async stop(delay) {
if (Helper.isNotNull(this.source)) { if (Helper.isNotNull(this.source)) {
this.pauseTime = ((new Date()).getTime()) - this.startTime; this.pauseTime = ((new Date()).getTime()) - this.startTime;
this.running = false;
return this.source.stop(delay); return this.source.stop(delay);
} }
this.running = false;
return null; return null;
} }
async resume() { async resume() {
if (!this.running) { if (!this.running) {
return this.start(null, Helper.nonNull(this.pauseTime, 0) / 1000.0); return this.start(null, Helper.nonNull(this.pauseTime, 0) / 1000.0);
} }
@ -6686,7 +6687,7 @@ class MenuSite extends WordRotatorBaseSite {
let playMusicButton = this.findBy("#play-music"); let playMusicButton = this.findBy("#play-music");
playMusicButton.checked = settingsManager.getSetting("play-music", true); playMusicButton.checked = settingsManager.getSetting("play-music", true);
playMusicButton.addEventListener("change", () => { playMusicButton.addEventListener("change", () => {
settingsManager.setSetting("play-music", playMusicButton.checked); settingsManager.setSetting("play-music", (playMusicButton.checked)?"1":"0");
soundManager.set({muted: !playMusicButton.checked}, SoundManager.CHANNELS.MUSIC); soundManager.set({muted: !playMusicButton.checked}, SoundManager.CHANNELS.MUSIC);
if (playMusicButton.checked) { if (playMusicButton.checked) {
soundManager.play(SoundManager.CHANNELS.MUSIC); soundManager.play(SoundManager.CHANNELS.MUSIC);
@ -6697,7 +6698,7 @@ class MenuSite extends WordRotatorBaseSite {
let playSoundButton = this.findBy("#play-sound"); let playSoundButton = this.findBy("#play-sound");
playSoundButton.checked = settingsManager.getSetting("play-sound", true); playSoundButton.checked = settingsManager.getSetting("play-sound", true);
playSoundButton.addEventListener("change", () => { playSoundButton.addEventListener("change", () => {
settingsManager.setSetting("play-sound", playSoundButton.checked); settingsManager.setSetting("play-sound", (playSoundButton.checked)?"1":"0");
soundManager.set({muted: !playSoundButton.checked}, SoundManager.CHANNELS.SOUND); soundManager.set({muted: !playSoundButton.checked}, SoundManager.CHANNELS.SOUND);
Matomo.push(["trackEvent", "MainMenu", "PlaySound", "Play Sound", (playSoundButton.checked) ? 1 : 0]); Matomo.push(["trackEvent", "MainMenu", "PlaySound", "Play Sound", (playSoundButton.checked) ? 1 : 0]);
}); });

View File

@ -323,7 +323,7 @@ class AudioChain {
await this.chainFunction(source); await this.chainFunction(source);
source.start(delay, offset, duration); source.start(delay, offset, duration);
this.startTime = (new Date()).getTime(); this.startTime = (new Date()).getTime() - (Helper.nonNull(offset, 0) * 1000);
this.source = source; this.source = source;
this.running = true; this.running = true;
} }
@ -331,13 +331,14 @@ class AudioChain {
async stop(delay) { async stop(delay) {
if (Helper.isNotNull(this.source)) { if (Helper.isNotNull(this.source)) {
this.pauseTime = ((new Date()).getTime()) - this.startTime; this.pauseTime = ((new Date()).getTime()) - this.startTime;
this.running = false;
return this.source.stop(delay); return this.source.stop(delay);
} }
this.running = false;
return null; return null;
} }
async resume() { async resume() {
if (!this.running) { if (!this.running) {
return this.start(null, Helper.nonNull(this.pauseTime, 0) / 1000.0); return this.start(null, Helper.nonNull(this.pauseTime, 0) / 1000.0);
} }

View File

@ -138,7 +138,7 @@ export class MenuSite extends WordRotatorBaseSite {
let playMusicButton = this.findBy("#play-music"); let playMusicButton = this.findBy("#play-music");
playMusicButton.checked = settingsManager.getSetting("play-music", true); playMusicButton.checked = settingsManager.getSetting("play-music", true);
playMusicButton.addEventListener("change", () => { playMusicButton.addEventListener("change", () => {
settingsManager.setSetting("play-music", playMusicButton.checked); settingsManager.setSetting("play-music", (playMusicButton.checked)?"1":"0");
soundManager.set({muted: !playMusicButton.checked}, SoundManager.CHANNELS.MUSIC); soundManager.set({muted: !playMusicButton.checked}, SoundManager.CHANNELS.MUSIC);
if (playMusicButton.checked) { if (playMusicButton.checked) {
soundManager.play(SoundManager.CHANNELS.MUSIC); soundManager.play(SoundManager.CHANNELS.MUSIC);
@ -149,7 +149,7 @@ export class MenuSite extends WordRotatorBaseSite {
let playSoundButton = this.findBy("#play-sound"); let playSoundButton = this.findBy("#play-sound");
playSoundButton.checked = settingsManager.getSetting("play-sound", true); playSoundButton.checked = settingsManager.getSetting("play-sound", true);
playSoundButton.addEventListener("change", () => { playSoundButton.addEventListener("change", () => {
settingsManager.setSetting("play-sound", playSoundButton.checked); settingsManager.setSetting("play-sound", (playSoundButton.checked)?"1":"0");
soundManager.set({muted: !playSoundButton.checked}, SoundManager.CHANNELS.SOUND); soundManager.set({muted: !playSoundButton.checked}, SoundManager.CHANNELS.SOUND);
Matomo.push(["trackEvent", "MainMenu", "PlaySound", "Play Sound", (playSoundButton.checked) ? 1 : 0]); Matomo.push(["trackEvent", "MainMenu", "PlaySound", "Play Sound", (playSoundButton.checked) ? 1 : 0]);
}); });