very niche error handling for no audio device id but still have error checking
This commit is contained in:
parent
a44071fedd
commit
ccb6f2c8b0
1 changed files with 15 additions and 11 deletions
|
@ -265,18 +265,22 @@ export const AudioPlayer = forwardRef(
|
|||
// Not standard, just used in chromium-based browsers. See
|
||||
// https://developer.chrome.com/blog/audiocontext-setsinkid/.
|
||||
// If the isElectron() check is every removed, fix this.
|
||||
if (isElectron() && webAudio && 'setSinkId' in webAudio.context) {
|
||||
try {
|
||||
if (audioDeviceId !== 'default') {
|
||||
// @ts-ignore
|
||||
webAudio.context.setSinkId(audioDeviceId);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
webAudio.context.setSinkId('');
|
||||
if (isElectron() && webAudio && 'setSinkId' in webAudio.context && audioDeviceId) {
|
||||
const setSink = async () => {
|
||||
try {
|
||||
if (audioDeviceId !== 'default') {
|
||||
// @ts-ignore
|
||||
await webAudio.context.setSinkId(audioDeviceId);
|
||||
} else {
|
||||
// @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]);
|
||||
|
||||
|
|
Reference in a new issue