Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

✨(frontend) allow user to test audio output

lebaudantoine9782eb8c7c61
diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json
index 50c7c8c4..b1b08286 100644
--- a/src/frontend/package-lock.json
+++ b/src/frontend/package-lock.json
@@ -37,7 +37,7 @@
"@typescript-eslint/parser": "7.13.1",
"@vitejs/plugin-react": "4.3.1",
"eslint": "8.57.0",
- "eslint-config-prettier": "^9.1.0",
+ "eslint-config-prettier": "9.1.0",
"eslint-plugin-jsx-a11y": "6.9.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.7",
@@ -454,7 +454,6 @@
},
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
"version": "1.3.0",
- "dev": true,
"inBundle": true,
"license": "MIT",
"engines": {
diff --git a/src/frontend/public/sounds/uprise.mp3 b/src/frontend/public/sounds/uprise.mp3
new file mode 100644
index 00000000..cacfba22
Binary files /dev/null and b/src/frontend/public/sounds/uprise.mp3 differ
diff --git a/src/frontend/src/components/SoundTester.tsx b/src/frontend/src/components/SoundTester.tsx
new file mode 100644
index 00000000..49cb661a
--- /dev/null
+++ b/src/frontend/src/components/SoundTester.tsx
@@ -0,0 +1,47 @@
+import { Button } from '@/primitives'
+import { useEffect, useRef, useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { useMediaDeviceSelect } from '@livekit/components-react'
+
+export const SoundTester = () => {
+ const { t } = useTranslation('settings')
+ const [isPlaying, setIsPlaying] = useState(false)
+ const audioRef = useRef<HTMLAudioElement>(null)
+
+ const { activeDeviceId } = useMediaDeviceSelect({ kind: 'audiooutput' })
+
+ useEffect(() => {
+ const updateActiveId = async (deviceId: string) => {
+ try {
+ await audioRef?.current?.setSinkId(deviceId)
+ } catch (error) {
+ console.error(`Error setting sinkId: ${error}`)
+ }
+ }
+ updateActiveId(activeDeviceId)
+ }, [activeDeviceId])
+
+ // prevent pausing the sound
+ navigator.mediaSession.setActionHandler('pause', function () {})
+
+ return (
+ <>
+ <Button
+ onPress={() => {
+ audioRef?.current?.play()
+ setIsPlaying(true)
+ }}
+ size="sm"
+ isDisabled={isPlaying}
+ >
+ {isPlaying ? t('audio.speakers.ongoingTest') : t('audio.speakers.test')}
+ </Button>
+ {/* eslint-disable jsx-a11y/media-has-caption */}
+ <audio
+ ref={audioRef}
+ src="sounds/uprise.mp3"
+ onEnded={() => setIsPlaying(false)}
+ />
+ </>
+ )
+}
diff --git a/src/frontend/src/features/settings/components/tabs/AudioTab.tsx b/src/frontend/src/features/settings/components/tabs/AudioTab.tsx
index e276f135..94e2a997 100644
--- a/src/frontend/src/features/settings/components/tabs/AudioTab.tsx
+++ b/src/frontend/src/features/settings/components/tabs/AudioTab.tsx
@@ -4,6 +4,7 @@ import { TabPanel, TabPanelProps } from '@/primitives/Tabs'
import { useMediaDeviceSelect } from '@livekit/components-react'
import { isSafari } from '@/utils/livekit'
import { useTranslation } from 'react-i18next'
+import { SoundTester } from '@/components/SoundTester.tsx'
export type AudioTabProps = Pick<DialogProps, 'onOpenChange'> &
Pick<TabPanelProps, 'id'>
@@ -80,9 +81,12 @@ export const AudioTab = ({ id }: AudioTabProps) => {
defaultSelectedKey={
activeDeviceIdOut || getDefaultSelectedKey(itemsOut)
}
- onSelectionChange={(key) => setActiveMediaDeviceOut(key as string)}
+ onSelectionChange={async (key) =>
+ setActiveMediaDeviceOut(key as string)
+ }
{...disabledProps}
/>
+ <SoundTester />
</>
)}
</TabPanel>
diff --git a/src/frontend/src/locales/de/settings.json b/src/frontend/src/locales/de/settings.json
index b3c09aab..4477733a 100644
--- a/src/frontend/src/locales/de/settings.json
+++ b/src/frontend/src/locales/de/settings.json
@@ -13,7 +13,9 @@
},
"speakers": {
"heading": "",
- "label": ""
+ "label": "",
+ "test": "",
+ "ongoingTest": ""
},
"permissionsRequired": ""
},
diff --git a/src/frontend/src/locales/en/settings.json b/src/frontend/src/locales/en/settings.json
index a1b51c49..296c4afd 100644
--- a/src/frontend/src/locales/en/settings.json
+++ b/src/frontend/src/locales/en/settings.json
@@ -13,7 +13,9 @@
},
"speakers": {
"heading": "Speakers",
- "label": "Select your audio output"
+ "label": "Select your audio output",
+ "test": "Test",
+ "ongoingTest": "Testing sound…"
},
"permissionsRequired": "Permissions required"
},
diff --git a/src/frontend/src/locales/fr/settings.json b/src/frontend/src/locales/fr/settings.json
index da64441f..2e149f49 100644
--- a/src/frontend/src/locales/fr/settings.json
+++ b/src/frontend/src/locales/fr/settings.json
@@ -13,7 +13,9 @@
},
"speakers": {
"heading": "Haut-parleurs",
- "label": "Sélectionner votre sortie audio"
+ "label": "Sélectionner votre sortie audio",
+ "test": "Tester",
+ "ongoingTest": "Test du son…"
},
"permissionsRequired": "Autorisations nécessaires"
},