🚸(frontend) draft sound design on notifications
More a brainsto idea inspired from Gmeet than a polished feature. Try adding sound notification to add a new dimension on the user experience.
This commit is contained in:
committed by
aleb_the_flash
parent
7edf7d194b
commit
d511aedd39
17
src/frontend/package-lock.json
generated
17
src/frontend/package-lock.json
generated
@@ -24,6 +24,7 @@
|
|||||||
"react-aria-components": "1.2.1",
|
"react-aria-components": "1.2.1",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-i18next": "14.1.3",
|
"react-i18next": "14.1.3",
|
||||||
|
"use-sound": "^4.0.3",
|
||||||
"valtio": "1.13.2",
|
"valtio": "1.13.2",
|
||||||
"wouter": "3.3.0"
|
"wouter": "3.3.0"
|
||||||
},
|
},
|
||||||
@@ -6695,6 +6696,11 @@
|
|||||||
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
|
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/howler": {
|
||||||
|
"version": "2.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/howler/-/howler-2.2.4.tgz",
|
||||||
|
"integrity": "sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w=="
|
||||||
|
},
|
||||||
"node_modules/html-parse-stringify": {
|
"node_modules/html-parse-stringify": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz",
|
||||||
@@ -10162,6 +10168,17 @@
|
|||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/use-sound": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/use-sound/-/use-sound-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-L205pEUFIrLsGYsCUKHQVCt0ajs//YQOFbEQeNwaWaqQj3y3st4SuR+rvpMHLmv8hgTcfUFlvMQawZNI3OE18w==",
|
||||||
|
"dependencies": {
|
||||||
|
"howler": "^2.1.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/use-sync-external-store": {
|
"node_modules/use-sync-external-store": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"react-aria-components": "1.2.1",
|
"react-aria-components": "1.2.1",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-i18next": "14.1.3",
|
"react-i18next": "14.1.3",
|
||||||
|
"use-sound": "4.0.3",
|
||||||
"valtio": "1.13.2",
|
"valtio": "1.13.2",
|
||||||
"wouter": "3.3.0"
|
"wouter": "3.3.0"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
src/frontend/public/sounds/notifications.mp3
Normal file
BIN
src/frontend/public/sounds/notifications.mp3
Normal file
Binary file not shown.
@@ -4,15 +4,19 @@ import { Participant, RemoteParticipant, RoomEvent } from 'livekit-client'
|
|||||||
import { ToastProvider, toastQueue } from './components/ToastProvider'
|
import { ToastProvider, toastQueue } from './components/ToastProvider'
|
||||||
import { NotificationType } from './NotificationType'
|
import { NotificationType } from './NotificationType'
|
||||||
import { Div } from '@/primitives'
|
import { Div } from '@/primitives'
|
||||||
import { isMobileBrowser } from '@livekit/components-core/src/helper/detectMobileBrowser.ts'
|
import { isMobileBrowser } from '@livekit/components-core'
|
||||||
|
import { useNotificationSound } from '@/features/notifications/hooks/useSoundNotification'
|
||||||
|
|
||||||
export const MainNotificationToast = () => {
|
export const MainNotificationToast = () => {
|
||||||
const room = useRoomContext()
|
const room = useRoomContext()
|
||||||
|
const { triggerNotificationSound } = useNotificationSound()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const showJoinNotification = (participant: Participant) => {
|
const showJoinNotification = (participant: Participant) => {
|
||||||
if (isMobileBrowser()) {
|
if (isMobileBrowser()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
triggerNotificationSound(NotificationType.Joined)
|
||||||
toastQueue.add(
|
toastQueue.add(
|
||||||
{
|
{
|
||||||
participant,
|
participant,
|
||||||
@@ -27,7 +31,7 @@ export const MainNotificationToast = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
room.off(RoomEvent.ParticipantConnected, showJoinNotification)
|
room.off(RoomEvent.ParticipantConnected, showJoinNotification)
|
||||||
}
|
}
|
||||||
}, [room])
|
}, [room, triggerNotificationSound])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const removeJoinNotification = (participant: Participant) => {
|
const removeJoinNotification = (participant: Participant) => {
|
||||||
@@ -71,6 +75,7 @@ export const MainNotificationToast = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!existingToast && notification === NotificationType.Raised) {
|
if (!existingToast && notification === NotificationType.Raised) {
|
||||||
|
triggerNotificationSound(NotificationType.Raised)
|
||||||
toastQueue.add(
|
toastQueue.add(
|
||||||
{
|
{
|
||||||
participant,
|
participant,
|
||||||
@@ -86,7 +91,7 @@ export const MainNotificationToast = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
room.off(RoomEvent.DataReceived, handleNotificationReceived)
|
room.off(RoomEvent.DataReceived, handleNotificationReceived)
|
||||||
}
|
}
|
||||||
}, [room])
|
}, [room, triggerNotificationSound])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Div position="absolute" bottom={20} right={5} zIndex={1000}>
|
<Div position="absolute" bottom={20} right={5} zIndex={1000}>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import useSound from 'use-sound'
|
||||||
|
|
||||||
|
// fixme - handle dynamic audio output changes
|
||||||
|
export const useNotificationSound = () => {
|
||||||
|
const [play] = useSound('./sounds/notifications.mp3', {
|
||||||
|
sprite: {
|
||||||
|
joined: [0, 1150],
|
||||||
|
raised: [1400, 180],
|
||||||
|
message: [1580, 300],
|
||||||
|
waiting: [2039, 710],
|
||||||
|
success: [2740, 1304],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const triggerNotificationSound = (type: string) => {
|
||||||
|
play({ id: type })
|
||||||
|
}
|
||||||
|
return { triggerNotificationSound }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user