Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tauri][wip] Custom audio outputs #768

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/AudioOutputSelect/AudioOutputSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default function AudioOutputSelect(props: Props) {
useEffect(() => {
const refreshDevices = async () => {
try {
// Webkit sucks, we need to request permissions for inputs, when we only
// need outputs
// const test = await navigator.mediaDevices.getUserMedia({
// audio: true,
// video: false,
// });
// This will display a popup to users asking them to give microphone access,
// which is lame because we only need outputs.
// Does not work on macOS/linux for now.
await navigator.mediaDevices.getUserMedia({
audio: true,
});
const devices = await navigator.mediaDevices.enumerateDevices();
const audioDevices = devices.filter(
(device) => device.kind === 'audiooutput' && device.deviceId !== '',
Expand Down
11 changes: 8 additions & 3 deletions src/lib/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ class Player {
this.track = null;

this.audio.defaultPlaybackRate = mergedOptions.playbackRate;
// @ts-ignore
// TODO:
// this.audio.setSinkId(mergedOptions.audioOutputDevice);

// FIXME: this will not do anything unless we recall getUserMedia()
if ('setSinkId' in this.audio) {
// eslint-disable-next-line
// @ts-ignore
this.audio.setSinkId(mergedOptions.audioOutputDevice);
}

this.audio.playbackRate = mergedOptions.playbackRate;
this.audio.volume = mergedOptions.volume;
this.audio.muted = mergedOptions.muted;
Expand Down
Loading