feat: add sound

This commit is contained in:
Dorian Zedler 2022-12-29 18:09:05 +01:00
parent 5885f63665
commit 0f610bd0cb
Signed by: dorian
GPG key ID: 989DE36109AFA354
2 changed files with 9 additions and 0 deletions

BIN
ding.mp3 Normal file

Binary file not shown.

View file

@ -81,6 +81,7 @@ document.addEventListener('alpine:init', () => {
connected: false, connected: false,
isMyTurn: false, isMyTurn: false,
_client: null, _client: null,
_audio: null,
init() { init() {
Alpine.effect(() => { Alpine.effect(() => {
@ -109,6 +110,14 @@ document.addEventListener('alpine:init', () => {
Alpine.store("localState").nextPlayer = nextPlayer; Alpine.store("localState").nextPlayer = nextPlayer;
} }
}) })
Alpine.effect(() => {
if(this.isMyTurn) {
this._audio.play();
}
})
this._audio = new Audio('ding.mp3');
}, },
connect() { connect() {