feat: add sound
This commit is contained in:
parent
5885f63665
commit
0f610bd0cb
2 changed files with 9 additions and 0 deletions
BIN
ding.mp3
Normal file
BIN
ding.mp3
Normal file
Binary file not shown.
9
index.js
9
index.js
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue