add error checking for set sink id (case of no devices at all)
This commit is contained in:
parent
b527d579fd
commit
a44071fedd
1 changed files with 10 additions and 6 deletions
|
@ -266,6 +266,7 @@ export const AudioPlayer = forwardRef(
|
||||||
// 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) {
|
||||||
|
try {
|
||||||
if (audioDeviceId !== 'default') {
|
if (audioDeviceId !== 'default') {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
webAudio.context.setSinkId(audioDeviceId);
|
webAudio.context.setSinkId(audioDeviceId);
|
||||||
|
@ -273,6 +274,9 @@ export const AudioPlayer = forwardRef(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
webAudio.context.setSinkId('');
|
webAudio.context.setSinkId('');
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error({ message: `Error setting sink: ${(error as Error).message}` });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [audioDeviceId, webAudio]);
|
}, [audioDeviceId, webAudio]);
|
||||||
|
|
||||||
|
|
Reference in a new issue