mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
add error checking for set sink id (case of no devices at all)
This commit is contained in:
@@ -266,12 +266,16 @@ export const AudioPlayer = forwardRef(
|
||||
// https://developer.chrome.com/blog/audiocontext-setsinkid/.
|
||||
// If the isElectron() check is every removed, fix this.
|
||||
if (isElectron() && webAudio && 'setSinkId' in webAudio.context) {
|
||||
if (audioDeviceId !== 'default') {
|
||||
// @ts-ignore
|
||||
webAudio.context.setSinkId(audioDeviceId);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
webAudio.context.setSinkId('');
|
||||
try {
|
||||
if (audioDeviceId !== 'default') {
|
||||
// @ts-ignore
|
||||
webAudio.context.setSinkId(audioDeviceId);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
webAudio.context.setSinkId('');
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error({ message: `Error setting sink: ${(error as Error).message}` });
|
||||
}
|
||||
}
|
||||
}, [audioDeviceId, webAudio]);
|
||||
|
||||
Reference in New Issue
Block a user