-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from heyngra/master
Add changable Audio Device, bugfixes
- Loading branch information
Showing
9 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.settings-item-container { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
margin-bottom: 10px; | ||
} | ||
.settings-item-container select { | ||
width: 50%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.settings-view .list .settings-item { | ||
min-height: 40px; | ||
width: 100%; | ||
} | ||
|
||
.settings-item .settings-item-container { | ||
width: 100%; | ||
height: 100%; | ||
display: grid; | ||
grid-template-columns: 80px 1fr; | ||
gap: 4px; | ||
overflow: hidden; | ||
font-size: 1em; | ||
border-radius: var(--border-radius); | ||
|
||
transition: background-color 250ms; | ||
} | ||
|
||
.list:not(.drag-inside) .settings-item .settings-item-container:hover, | ||
.settings-item.selected .settings-item-container, | ||
[data-dragged] .settings-item-container { | ||
background-color: rgba(var(--color-fg), var(--level-0)); | ||
|
||
transition: background-color 0ms; | ||
} | ||
|
||
.settings-view .list .settings-item .column { | ||
display: flex; | ||
flex-direction: column; | ||
align-self: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.settings-view { | ||
display: flex; | ||
flex-direction: column; | ||
overflow: hidden; | ||
} | ||
|
||
.settings-view > :not(.no-pd) { | ||
padding: 16px; | ||
} | ||
|
||
.settings-view .list { | ||
position: relative; /* used for setting offsetParent for .settings-item elements */ | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
margin-top: 16px; | ||
padding: 0 16px 16vw 16px; | ||
overflow: auto; | ||
} | ||
|
||
.list.drag-inside { | ||
cursor: move; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Component, Show } from 'solid-js'; | ||
|
||
import "../../assets/css/select.css"; | ||
|
||
type SettingDropdownProps = { | ||
label: string, | ||
options: Map<string, () => any>, // name of option, function after clicked | ||
disabled: false, | ||
} | ||
|
||
const SettingDropdown: Component<SettingDropdownProps> = props => { | ||
|
||
const changeOption = (e: Event) => { | ||
const option = (e.target as HTMLSelectElement).value; | ||
const functionToCall = props.options.get(option); | ||
if (functionToCall !== undefined) { | ||
functionToCall(); | ||
} | ||
} | ||
|
||
return ( | ||
<div class="settings-item"> | ||
<div class="settings-item-container"> | ||
<label>{props.label}</label> | ||
<Show when={props.options.size > 0} fallback={<div>Loading audio devices</div>}> | ||
<select class="button-like select" disabled={props.disabled} onChange={changeOption}> | ||
{ | ||
Array.from(props.options.keys()).map(option => ( | ||
<option value={option}>{option}</option> | ||
))} | ||
</select> | ||
</Show> | ||
</div> | ||
</div> | ||
); | ||
} | ||
export default SettingDropdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import SettingDropdown from './SettingDropdown'; | ||
import "../../assets/css/settings/settings-view.css"; | ||
import "../../assets/css/settings/settings-item.css"; | ||
import { createEffect, createSignal, onMount } from 'solid-js'; | ||
import { changeAudioDevice} from '../../lib/Music'; | ||
|
||
const SettingsView = () => { | ||
let view; | ||
|
||
const [audioDevices, setAudioDevices] = createSignal(new Map<string, ()=>any>()); | ||
|
||
const setAudioDevicesMap = () => { | ||
const audioMap = new Map<string, ()=>any>(); | ||
navigator.mediaDevices.enumerateDevices().then(r => { | ||
for (const device of r) { | ||
if (device.kind === "audiooutput") { | ||
audioMap.set(device.label, () => changeAudioDevice(device.deviceId)); | ||
} | ||
} | ||
setAudioDevices(audioMap); | ||
}); | ||
} | ||
|
||
onMount(() => { | ||
createEffect(setAudioDevicesMap); | ||
}) | ||
|
||
return ( | ||
<div | ||
ref={view} | ||
class="settings-view" | ||
> | ||
<div class="list"> | ||
<SettingDropdown | ||
disabled={false} | ||
label={"Choose audio device"} | ||
options={audioDevices()}/> | ||
</div> | ||
</div> | ||
) | ||
} | ||
export default SettingsView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters