Skip to content

Commit 7fd1b36

Browse files
committed
Attempt to make custom audio outputs work again
1 parent 1932930 commit 7fd1b36

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/components/AudioOutputSelect/AudioOutputSelect.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export default function AudioOutputSelect(props: Props) {
1919
useEffect(() => {
2020
const refreshDevices = async () => {
2121
try {
22-
// Webkit sucks, we need to request permissions for inputs, when we only
23-
// need outputs
24-
// const test = await navigator.mediaDevices.getUserMedia({
25-
// audio: true,
26-
// video: false,
27-
// });
22+
// This will display a popup to users asking them to give microphone access,
23+
// which is lame because we only need outputs.
24+
// Does not work on macOS/linux for now.
25+
await navigator.mediaDevices.getUserMedia({
26+
audio: true,
27+
});
2828
const devices = await navigator.mediaDevices.enumerateDevices();
2929
const audioDevices = devices.filter(
3030
(device) => device.kind === 'audiooutput' && device.deviceId !== '',

src/lib/player.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ class Player {
3737
this.track = null;
3838

3939
this.audio.defaultPlaybackRate = mergedOptions.playbackRate;
40-
// @ts-ignore
41-
// TODO:
42-
// this.audio.setSinkId(mergedOptions.audioOutputDevice);
40+
41+
// FIXME: this will not do anything unless we recall getUserMedia()
42+
if ('setSinkId' in this.audio) {
43+
// eslint-disable-next-line
44+
// @ts-ignore
45+
this.audio.setSinkId(mergedOptions.audioOutputDevice);
46+
}
47+
4348
this.audio.playbackRate = mergedOptions.playbackRate;
4449
this.audio.volume = mergedOptions.volume;
4550
this.audio.muted = mergedOptions.muted;

0 commit comments

Comments
 (0)