Check if audio device is output
This commit is contained in:
parent
ed87c797ba
commit
7f63c09141
2 changed files with 12 additions and 6 deletions
9
menus.py
9
menus.py
|
@ -1568,9 +1568,12 @@ class PesterOptions(QtWidgets.QDialog):
|
||||||
current_audio_device = self.config.audioDevice()
|
current_audio_device = self.config.audioDevice()
|
||||||
active_index = None
|
active_index = None
|
||||||
try:
|
try:
|
||||||
for i, output in enumerate(QtMultimedia.QMediaDevices.audioOutputs()):
|
for i, device in enumerate(QtMultimedia.QMediaDevices.audioOutputs()):
|
||||||
self.audioDeviceBox.addItem(f"{output.description()}", output.id())
|
self.audioDeviceBox.addItem(f"{device.description()}", device.id())
|
||||||
if output.id() == current_audio_device:
|
if (
|
||||||
|
device.id() == current_audio_device
|
||||||
|
and device.Mode == QtMultimedia.QAudioDevice.Mode.Output
|
||||||
|
):
|
||||||
active_index = i
|
active_index = i
|
||||||
if active_index is not None:
|
if active_index is not None:
|
||||||
self.audioDeviceBox.setCurrentIndex(active_index)
|
self.audioDeviceBox.setCurrentIndex(active_index)
|
||||||
|
|
|
@ -2473,10 +2473,13 @@ class PesterWindow(MovingWindow):
|
||||||
if "QtMultimedia" not in globals():
|
if "QtMultimedia" not in globals():
|
||||||
PchumLog.warning("Not using QtMultimedia, can't set audio device.")
|
PchumLog.warning("Not using QtMultimedia, can't set audio device.")
|
||||||
return
|
return
|
||||||
for output in QtMultimedia.QMediaDevices.audioOutputs():
|
for device in QtMultimedia.QMediaDevices.audioOutputs():
|
||||||
if device_id == output.id():
|
if (
|
||||||
|
device_id == device.id()
|
||||||
|
and device.Mode == QtMultimedia.QAudioDevice.Mode.Output
|
||||||
|
):
|
||||||
for sound in self.sounds:
|
for sound in self.sounds:
|
||||||
sound.setAudioDevice(output)
|
sound.setAudioDevice(device)
|
||||||
|
|
||||||
def canSetVolume(self):
|
def canSetVolume(self):
|
||||||
"""Returns the state of volume setting capabilities."""
|
"""Returns the state of volume setting capabilities."""
|
||||||
|
|
Loading…
Reference in a new issue