Join and leave sfx
This commit is contained in:
@@ -11,6 +11,7 @@ import { Channel } from "@/lib/types";
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { ClientMethod } from "./protocol";
|
import { ClientMethod } from "./protocol";
|
||||||
import { BackendConfig, Config, getConfig } from "@/lib/config";
|
import { BackendConfig, Config, getConfig } from "@/lib/config";
|
||||||
|
import { playJoin, playLeave } from "@/lib/soundEffects";
|
||||||
|
|
||||||
ed.hashes.sha512 = sha512;
|
ed.hashes.sha512 = sha512;
|
||||||
|
|
||||||
@@ -220,6 +221,8 @@ export default class Enclave<P = Page> {
|
|||||||
server.voiceChatSpeakers = {};
|
server.voiceChatSpeakers = {};
|
||||||
|
|
||||||
this.forceRender();
|
this.forceRender();
|
||||||
|
|
||||||
|
playLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onMessage(msg: ClientMethod) {
|
public async onMessage(msg: ClientMethod) {
|
||||||
@@ -290,6 +293,11 @@ export default class Enclave<P = Page> {
|
|||||||
|
|
||||||
server.voiceChatUsers[msg.channel_id].push(msg.pubkey);
|
server.voiceChatUsers[msg.channel_id].push(msg.pubkey);
|
||||||
this.server?.getUsers([msg.pubkey]);
|
this.server?.getUsers([msg.pubkey]);
|
||||||
|
|
||||||
|
if (msg.channel_id === this.server?.voiceChannelId) {
|
||||||
|
playJoin();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "UserLeftVoice":
|
case "UserLeftVoice":
|
||||||
@@ -301,6 +309,10 @@ export default class Enclave<P = Page> {
|
|||||||
|
|
||||||
this.forceRender();
|
this.forceRender();
|
||||||
|
|
||||||
|
if (msg.channel_id === this.server?.voiceChannelId) {
|
||||||
|
playLeave();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "Speaking":
|
case "Speaking":
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
|||||||
|
import joinSfx from "@/assets/join.wav";
|
||||||
|
import leaveSfx from "@/assets/leave.wav";
|
||||||
|
|
||||||
|
export function playJoin() {
|
||||||
|
const audio = new Audio(joinSfx);
|
||||||
|
|
||||||
|
audio.currentTime = 0;
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function playLeave() {
|
||||||
|
const audio = new Audio(leaveSfx);
|
||||||
|
|
||||||
|
audio.currentTime = 0;
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user