Try to change default audio output device on MacOS
-
Hi,
I tried to change the default audio output device on MacOS.
Here is my code:
from PySide6 import QtMultimedia devices = QtMultimedia.QMediaDevices.audioOutputs() device_list = {} number = 1 for device in devices: default = " " device_list[str(number)] = QtMultimedia.QAudioDevice(device) if device.isDefault(): default = "#" print(f"{default} {number} - {device.description()}") number += 1 choice = input("> ") QtMultimedia.QAudioOutput.setDevice(device_list[choice])
I have tried multiple way to accomplish that.
When I try to useQtMultimedia.QAudioOutput.setDevice()
I got the following error.TypeError: descriptor 'setDevice' for 'PySide6.QtMultimedia.QAudioOutput' objects doesn't apply to a 'PySide6.QtMultimedia.QAudioDevice' object
In the documentation,
setDevice
need aPySide6.QtMultimedia.QAudioDevice
object. And this is what I use.What am I doing wrong? What have I not understood?
Thanks
-
Hi,
I tried to change the default audio output device on MacOS.
Here is my code:
from PySide6 import QtMultimedia devices = QtMultimedia.QMediaDevices.audioOutputs() device_list = {} number = 1 for device in devices: default = " " device_list[str(number)] = QtMultimedia.QAudioDevice(device) if device.isDefault(): default = "#" print(f"{default} {number} - {device.description()}") number += 1 choice = input("> ") QtMultimedia.QAudioOutput.setDevice(device_list[choice])
I have tried multiple way to accomplish that.
When I try to useQtMultimedia.QAudioOutput.setDevice()
I got the following error.TypeError: descriptor 'setDevice' for 'PySide6.QtMultimedia.QAudioOutput' objects doesn't apply to a 'PySide6.QtMultimedia.QAudioDevice' object
In the documentation,
setDevice
need aPySide6.QtMultimedia.QAudioDevice
object. And this is what I use.What am I doing wrong? What have I not understood?
Thanks
Hi and welcome to devnet,
You are calling an instance method on a class. You need to call setDevice on the instance of QAudioOutput that you are going to use in your application.
-
Hi and welcome to devnet,
You are calling an instance method on a class. You need to call setDevice on the instance of QAudioOutput that you are going to use in your application.
-
I have tried to create an instance of QAudioOutput with the device as parameter, but setDevice needs the device too, whatever.
And in this case nothing happend.Do you have any example ?
What exactly did you do ?
-
I think I made a mistake.
I try to change the default audio output for the entire system, not for my application.My application as no audio. His purpose is only for changing audio output for all application.
Then you will have to use system APIs, if any exists, for that kind of use case. Changing system settings is outside the scope of Qt.
-
Then you will have to use system APIs, if any exists, for that kind of use case. Changing system settings is outside the scope of Qt.
-