Skip to content

Commit

Permalink
✨ [Sound] Emit volume and mute events
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Dec 21, 2023
1 parent bbf7a99 commit a40ce7f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export class Sound extends EmittenCommon<SoundEventMap> {

this._volume = newVolume;

if (oldVolume !== newVolume) {
this.emit('volume', newVolume);
}

if (this._mute) return;

this.#gainNode.gain
Expand All @@ -66,6 +70,10 @@ export class Sound extends EmittenCommon<SoundEventMap> {
}

set mute(value: boolean) {
if (this._mute !== value) {
this.emit('mute', value);
}

this._mute = value;

const fromValue = value ? this._volume : 0;
Expand Down

0 comments on commit a40ce7f

Please sign in to comment.