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,
|
||||
isMyTurn: false,
|
||||
_client: null,
|
||||
_audio: null,
|
||||
|
||||
init() {
|
||||
Alpine.effect(() => {
|
||||
|
@ -109,6 +110,14 @@ document.addEventListener('alpine:init', () => {
|
|||
Alpine.store("localState").nextPlayer = nextPlayer;
|
||||
}
|
||||
})
|
||||
|
||||
Alpine.effect(() => {
|
||||
if(this.isMyTurn) {
|
||||
this._audio.play();
|
||||
}
|
||||
})
|
||||
|
||||
this._audio = new Audio('ding.mp3');
|
||||
},
|
||||
|
||||
connect() {
|
||||
|
|
Loading…
Reference in a new issue