mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-19 19:14:53 +00:00
23 lines
411 B
JavaScript
23 lines
411 B
JavaScript
export default class AudioHandler {
|
|
constructor() {
|
|
this._beep = window.Audio && new window.Audio('beep.mp3') || false;
|
|
this._soundEnabled = true;
|
|
}
|
|
|
|
get soundEnabled() {
|
|
return this._soundEnabled;
|
|
}
|
|
|
|
set soundEnabled(state) {
|
|
this._soundEnabled = state;
|
|
return this;
|
|
}
|
|
|
|
play() {
|
|
if (this._beep && this.soundEnabled) {
|
|
this._beep.play();
|
|
}
|
|
return this;
|
|
}
|
|
}
|