Add join and leave sounds
This commit is contained in:
@@ -134,6 +134,15 @@ const onActiveSpeakersChanged = (participants: {identity: string}[]) => {
|
||||
speakingPubkeys.set(new Set(participants.map(p => p.identity)))
|
||||
}
|
||||
|
||||
const playJoinSound = () => {
|
||||
const audio = new Audio("/join-voice-room.mp3")
|
||||
audio.play().catch(() => {})
|
||||
}
|
||||
|
||||
const onParticipantConnected = () => {
|
||||
playJoinSound()
|
||||
}
|
||||
|
||||
export const joinVoiceRoom = async (
|
||||
url: string,
|
||||
h: string,
|
||||
@@ -150,6 +159,7 @@ export const joinVoiceRoom = async (
|
||||
const room = new Room({adaptiveStream: true, dynacast: true})
|
||||
|
||||
room.on(RoomEvent.Disconnected, onRoomDisconnected)
|
||||
room.on(RoomEvent.ParticipantConnected, onParticipantConnected)
|
||||
room.on(RoomEvent.TrackSubscribed, onTrackSubscribed)
|
||||
room.on(RoomEvent.TrackUnsubscribed, onTrackUnsubscribed)
|
||||
room.on(RoomEvent.ActiveSpeakersChanged, onActiveSpeakersChanged)
|
||||
@@ -179,12 +189,17 @@ export const joinVoiceRoom = async (
|
||||
currentVoiceSession.set({url, h, room, muted})
|
||||
|
||||
startPresenceHeartbeat(url, h)
|
||||
|
||||
playJoinSound()
|
||||
}
|
||||
|
||||
export const leaveVoiceRoom = async () => {
|
||||
const session = get(currentVoiceSession)
|
||||
if (!session) return
|
||||
|
||||
const audio = new Audio("/leave-voice-room.mp3")
|
||||
audio.play().catch(() => {})
|
||||
|
||||
speakingPubkeys.set(new Set())
|
||||
stopPresenceHeartbeat()
|
||||
session.room.disconnect()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user