Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-126203

[darwin] MediaPlayer does not always take into account the selected audio output device

    XMLWordPrintable

Details

    • macOS
    • cf092077e (dev), afd504142 (6.8), 53215b6d0 (6.7), 048a7e3eb (tqtc/lts-6.5)
    • Multimedia Next

    Description

      MediaPlayer does not take into account the selected audio output device if it was set immediately before playback started.
      Can be reproduced with "darwin" multimedia backend.

      Sample code:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      import QtMultimedia
      
      Window {
          width: 640
          height: 480
          visible: true
      
          RowLayout {
              ComboBox {
                  id: devicesList
                  Layout.preferredWidth: 200
      
                  textRole: "text"
                  valueRole: "value"
                  model: {
                      const defaultDevice = devices.defaultAudioOutput
                      let deviceNames = [{text: 'Default (%1)'.arg(defaultDevice.description), value: defaultDevice}]
                      for (let device of devices.audioOutputs)
                          deviceNames.push({text: device.description, value: device})
                      return deviceNames
                  }
              }
              Button {
                  text: playerLoader.active ? 'Stop' : 'Play'
                  onClicked: playerLoader.active = !playerLoader.active
              }
      
              CheckBox {
                  id: inLoop
                  text: 'loop?'
              }
          }
      
          MediaDevices { id: devices }
      
          Loader {
              id: playerLoader
              active: false
              sourceComponent: MediaPlayer {
                  id: player
                  audioOutput: AudioOutput {
                      device: devicesList.currentValue
                      onDeviceChanged: console.log('Selected device:' + device)
                  }
                  autoPlay: true
                  loops: inLoop.checked ? MediaPlayer.Infinite : 1
                  source: 'nokia-tune.mp3'
              }
          }
      }
      

      See full example audio_output.zip

      Steps to reproduce:
      1. Plug-in any headphones (I tried wired ones) to your Mac Book
      2. Run sample program
      3. Select an output device which is not currently default in the system
      4. Press "Play" button and check which device is playing audio

      Actual results: sound is always playing through the default audio output
      Expected results: sound is playing through the selected audio output

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtmultimediateam Qt Multimedia Team
            studiosus Vladimir Belyavsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews