Sort audio outputs
This commit is contained in:
parent
ccb5886698
commit
fe80b803f8
3 changed files with 15 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
from typing import Any, Dict
|
||||
from typing import Any, Dict, List
|
||||
import sounddevice as sd
|
||||
from helpers.os_environment import isMacOS
|
||||
|
||||
|
@ -10,7 +10,7 @@ class DeviceManager():
|
|||
return device["max_output_channels"] > 0
|
||||
|
||||
@classmethod
|
||||
def _getDevices(cls) -> sd.DeviceList:
|
||||
def _getAudioDevices(cls) -> sd.DeviceList:
|
||||
# To update the list of devices
|
||||
# Sadly this doesn't work on MacOS.
|
||||
if not isMacOS():
|
||||
|
@ -20,7 +20,7 @@ class DeviceManager():
|
|||
return devices
|
||||
|
||||
@classmethod
|
||||
def getOutputs(cls) -> sd.DeviceList:
|
||||
outputs: sd.DeviceList = filter(cls._isOutput, cls._getDevices())
|
||||
|
||||
return outputs
|
||||
def getAudioOutputs(cls) -> List[Dict]:
|
||||
outputs: List[Dict] = list(filter(cls._isOutput, cls._getAudioDevices()))
|
||||
outputs = sorted(outputs, key=lambda k: k['name'])
|
||||
return [{"name": None}] + outputs
|
||||
|
|
|
@ -130,7 +130,7 @@ def ui_config():
|
|||
for i in range(state.state["num_channels"]):
|
||||
channel_states.append(status(i))
|
||||
|
||||
outputs = DeviceManager.getOutputs()
|
||||
outputs = DeviceManager.getAudioOutputs()
|
||||
|
||||
data = {
|
||||
'channels': channel_states,
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content_inner %}
|
||||
<h3 class="h5">Audio Outputs</h3>
|
||||
<code>
|
||||
<a href="/player/0/output/none">Set Channel 0</a> <a href="/player/1/output/none">Set Channel 1</a> <a href="/player/2/output/none">Set Channel 2</a> - System Default Output<br>
|
||||
|
||||
{% for output in data.outputs %}
|
||||
<a href="/player/0/output/{{output.name}}">Set Channel 0</a> <a href="/player/1/output/{{output.name}}">Set Channel 1</a> <a href="/player/2/output/{{output.name}}">Set Channel 2</a> - {{output.name}}<br>
|
||||
|
||||
Set for:
|
||||
{% for channel in data.channels %}
|
||||
<a href="/player/{{channel.channel}}/output/none">Channel {{channel.channel}}</a>
|
||||
{% endfor %}
|
||||
- {% if output.name %}{{output.name}}{% else %}System Default Output{% endif %}<br>
|
||||
{% endfor %}
|
||||
</code>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue