mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 14:37:06 +01:00
very niche error handling for no audio device id but still have error checking
This commit is contained in:
parent
a44071fedd
commit
ccb6f2c8b0
@ -265,18 +265,22 @@ export const AudioPlayer = forwardRef(
|
|||||||
// Not standard, just used in chromium-based browsers. See
|
// Not standard, just used in chromium-based browsers. See
|
||||||
// https://developer.chrome.com/blog/audiocontext-setsinkid/.
|
// https://developer.chrome.com/blog/audiocontext-setsinkid/.
|
||||||
// If the isElectron() check is every removed, fix this.
|
// If the isElectron() check is every removed, fix this.
|
||||||
if (isElectron() && webAudio && 'setSinkId' in webAudio.context) {
|
if (isElectron() && webAudio && 'setSinkId' in webAudio.context && audioDeviceId) {
|
||||||
try {
|
const setSink = async () => {
|
||||||
if (audioDeviceId !== 'default') {
|
try {
|
||||||
// @ts-ignore
|
if (audioDeviceId !== 'default') {
|
||||||
webAudio.context.setSinkId(audioDeviceId);
|
// @ts-ignore
|
||||||
} else {
|
await webAudio.context.setSinkId(audioDeviceId);
|
||||||
// @ts-ignore
|
} else {
|
||||||
webAudio.context.setSinkId('');
|
// @ts-ignore
|
||||||
|
await webAudio.context.setSinkId('');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error({ message: `Error setting sink: ${(error as Error).message}` });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
};
|
||||||
toast.error({ message: `Error setting sink: ${(error as Error).message}` });
|
|
||||||
}
|
setSink();
|
||||||
}
|
}
|
||||||
}, [audioDeviceId, webAudio]);
|
}, [audioDeviceId, webAudio]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user