Skip to content

Commit

Permalink
Fix controlling mute & volume level of single global music instance
Browse files Browse the repository at this point in the history
Closes: #688
  • Loading branch information
AntumDeluge committed Mar 18, 2024
1 parent 6b57ebe commit 22fa54a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions srcjs/stendhal/ui/SoundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ export class SoundManager {
/**
* Stops all currently playing sounds.
*
* NOTE: this if for map changes & should not include single global music instance
*
* @param includeGui {boolean}
* If `true`, sounds on the gui layer will stopped as well (default: false).
* @return {boolean}
Expand Down Expand Up @@ -541,6 +543,11 @@ export class SoundManager {
muted = muted && snd.muted;
}
}
// global music is not tracked in layer array
if (this.globalMusic) {
this.globalMusic.muted = true;
muted = muted && this.globalMusic.muted;
}
return muted;
}

Expand All @@ -558,6 +565,11 @@ export class SoundManager {
unmuted = unmuted && !snd.paused && !snd.muted;
}
}
// global music is not tracked in layer array
if (this.globalMusic) {
this.globalMusic.muted = false;
unmuted = unmuted && !this.globalMusic.paused && !this.globalMusic.muted;
}
return unmuted;
}

Expand Down Expand Up @@ -680,6 +692,10 @@ export class SoundManager {
}
}
}
// global music is not tracked in layer array
if (this.globalMusic && (layerName === "music" || layerName === "master")) {
this.applyAdjustedVolume(layerName, this.globalMusic);
}
return true;
}

Expand Down

0 comments on commit 22fa54a

Please sign in to comment.