Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Changing the Audio Output Device?

Changing the Audio Output Device?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    respect88
    wrote on last edited by respect88
    #1

    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)

    1 Reply Last reply
    0
    • kenneth.fernandezK Offline
      kenneth.fernandezK Offline
      kenneth.fernandez
      wrote on last edited by
      #2

      @respect88 said in Changing the Audio Output Device?:

      (https://doc.qt.io/qt-5/qml-qtmultimedia-audio.html)

      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.html

      Python

      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.html

      I hope this would be useful,

      --
      Lic-Ing. Kenneth Fernández Esquivel
      Embedded Software Engineer
      RidgeRun Engineering Ltd.
      www.ridgerun.com
      Email: kenneth.fernandez@ridgerun.com
       San Juan, La Unión. Cartago. Costa Rica

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved