Changing the Audio Output Device?
-
My computer has 2 sound cards. I would like to set which device is used for audio output. I am using QML/Python.
I am using a simple example like this:
Text { text: "Click Me!"; font.pointSize: 24; width: 150; height: 50; Audio { id: playMusic source: "music.wav" } MouseArea { id: playArea anchors.fill: parent onPressed: { playMusic.play() } } }
I couldn't find any thing related to changing the output device in the Audio QML documentation (https://doc.qt.io/qt-5/qml-qtmultimedia-audio.html)
-
@respect88 said in Changing the Audio Output Device?:
Hi @respect88,
You must make those changes directly in Python, because the QML element does not have such feature. On the other side of the coin, QML has the ability to use JavaScript functions, you could force it, but still that is not a good practice, it is better to do things in the way they were designed and respecting the main objective of each layer. So, Python is the place, as it is more natural to make a class in the lower layers to talk with the devices controllers/drives/API.
Here are some references:
C++
https://doc.qt.io/qt-5/qtmultimedia-multimedia-audiooutput-example.html
https://doc.qt.io/qt-5/qaudiooutput.htmlPython
https://doc.qt.io/archives/qtforpython-5.12/PySide2/QtMultimedia/QAudioOutput.html
https://doc-snapshots.qt.io/qtforpython-5.15/overviews/qtmultimedia-multimedia-audiooutput-example.htmlI hope this would be useful,