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

feat: Output Source Selection #25

Open
wants to merge 1 commit into
base: main
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
43 changes: 43 additions & 0 deletions app/components/AudioOutputSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { FC } from 'react'
import { useAudioOutputDeviceId } from '~/hooks/globalPersistedState'
import useMediaDevices from '~/hooks/useMediaDevices'
import { useRoomContext } from '~/hooks/useRoomContext'
import { errorMessageMap } from '~/hooks/useUserMedia'
import { Option, Select } from './Select'

export const AudioOutputSelector: FC<{ id?: string }> = ({ id }) => {
const audioOutputDevices = useMediaDevices((d) => d.kind === 'audiooutput')
const [audioDeviceId, setAudioDeviceId] = useAudioOutputDeviceId()

const {
userMedia: { audioUnavailableReason },
} = useRoomContext()

if (audioUnavailableReason) {
return (
<div className="max-w-[40ch]">
<Select
tooltipContent={errorMessageMap[audioUnavailableReason]}
id={id}
defaultValue="unavailable"
>
<Option value={'unavailable'}>(Unavailable)</Option>
</Select>
</div>
)
}

if (!audioDeviceId) return <span>null</span>

return (
<div className="max-w-[40ch]">
<Select id={id} value={audioDeviceId} onValueChange={setAudioDeviceId}>
{audioOutputDevices.map((d) => (
<Option key={d.deviceId} value={d.deviceId}>
{d.label}
</Option>
))}
</Select>
</div>
)
}
9 changes: 9 additions & 0 deletions app/components/SettingsDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { FC, ReactNode } from 'react'
import { useRoomContext } from '~/hooks/useRoomContext'
import { AudioInputSelector } from './AudioInputSelector'
import { AudioOutputSelector } from './AudioOutputSelector'

import { Button } from './Button'
import {
Dialog,
Expand Down Expand Up @@ -67,6 +69,13 @@ export const SettingsDialog: FC<SettingsDialogProps> = ({
Mic
</Label>
<AudioInputSelector id="mic" />
<Label
className="text-base -mb-2 md:mb-0 text-left md:text-right"
htmlFor="mic"
>
Audio
</Label>
<AudioOutputSelector id="audio" />
<Label
className="text-base -mb-2 md:mb-0 text-left md:text-right"
htmlFor="blurBackground"
Expand Down