Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Try to change default audio output device on MacOS
Servers for Qt installer are currently down

Try to change default audio output device on MacOS

Scheduled Pinned Locked Moved Solved Qt for Python
7 Posts 2 Posters 538 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Salamafet
    wrote on 6 Apr 2023, 15:12 last edited by
    #1

    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 use QtMultimedia.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, setDeviceneed a PySide6.QtMultimedia.QAudioDevice object. And this is what I use.

    What am I doing wrong? What have I not understood?

    Thanks

    S 1 Reply Last reply 6 Apr 2023, 19:10
    0
    • S Salamafet
      6 Apr 2023, 15:12

      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 use QtMultimedia.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, setDeviceneed a PySide6.QtMultimedia.QAudioDevice object. And this is what I use.

      What am I doing wrong? What have I not understood?

      Thanks

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Apr 2023, 19:10 last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 6 Apr 2023, 20:51
      0
      • S SGaist
        6 Apr 2023, 19:10

        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.

        S Offline
        S Offline
        Salamafet
        wrote on 6 Apr 2023, 20:51 last edited by Salamafet 4 Jun 2023, 20:52
        #3

        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 ?

        S 1 Reply Last reply 7 Apr 2023, 20:13
        0
        • S Salamafet
          6 Apr 2023, 20:51

          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 ?

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Apr 2023, 20:13 last edited by
          #4

          What exactly did you do ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 11 Apr 2023, 07:17
          0
          • S SGaist
            7 Apr 2023, 20:13

            What exactly did you do ?

            S Offline
            S Offline
            Salamafet
            wrote on 11 Apr 2023, 07:17 last edited by
            #5

            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.

            S 1 Reply Last reply 11 Apr 2023, 20:19
            0
            • S Salamafet
              11 Apr 2023, 07:17

              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.

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 11 Apr 2023, 20:19 last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply 12 Apr 2023, 14:17
              0
              • S SGaist
                11 Apr 2023, 20:19

                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.

                S Offline
                S Offline
                Salamafet
                wrote on 12 Apr 2023, 14:17 last edited by
                #7

                Thanks for your help.

                1 Reply Last reply
                0
                • S Salamafet has marked this topic as solved on 12 Apr 2023, 14:18

                1/7

                6 Apr 2023, 15:12

                • Login

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