[bugfix]: use chrome-specific implementation for web audio sink
This commit is contained in:
parent
ebebdc1e03
commit
af69a58418
1 changed files with 10 additions and 7 deletions
|
@ -262,16 +262,19 @@ export const AudioPlayer = forwardRef(
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isElectron()) {
|
// Not standard, just used in chromium-based browsers. See
|
||||||
if (audioDeviceId) {
|
// https://developer.chrome.com/blog/audiocontext-setsinkid/.
|
||||||
player1Ref.current?.getInternalPlayer()?.setSinkId(audioDeviceId);
|
// If the isElectron() check is every removed, fix this.
|
||||||
player2Ref.current?.getInternalPlayer()?.setSinkId(audioDeviceId);
|
if (isElectron() && webAudio && 'setSinkId' in webAudio.context) {
|
||||||
|
if (audioDeviceId !== 'default') {
|
||||||
|
// @ts-ignore
|
||||||
|
webAudio.context.setSinkId(audioDeviceId);
|
||||||
} else {
|
} else {
|
||||||
player1Ref.current?.getInternalPlayer()?.setSinkId('');
|
// @ts-ignore
|
||||||
player2Ref.current?.getInternalPlayer()?.setSinkId('');
|
webAudio.context.setSinkId('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [audioDeviceId]);
|
}, [audioDeviceId, webAudio]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (webAudio && player1Source && player1 && currentPlayer === 1) {
|
if (webAudio && player1Source && player1 && currentPlayer === 1) {
|
||||||
|
|
Reference in a new issue