don't set sink on closed context

This commit is contained in:
Kendall Garner 2025-07-02 19:19:51 -07:00
parent 176a95a946
commit caa9448200
No known key found for this signature in database
GPG key ID: 9355F387FE765C94

View file

@ -322,10 +322,8 @@ export const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>((props,
if (isElectron() && webAudio && 'setSinkId' in webAudio.context && audioDeviceId) {
const setSink = async () => {
try {
if (audioDeviceId !== 'default') {
if (webAudio.context.state !== 'closed') {
await (webAudio.context as any).setSinkId(audioDeviceId);
} else {
await (webAudio.context as any).setSinkId('');
}
} catch (error) {
toast.error({ message: `Error setting sink: ${(error as Error).message}` });