Home > front end >  How to use Qt MediaDevices type to switch AudioOutput device
How to use Qt MediaDevices type to switch AudioOutput device

Time:01-16

I think I'm missing something here, but I can't figure out how to set a AudioOutput device from MediaDevices audioOutputs list with the QML Components

audioOutput: AudioOutput {
    id: playerOutput
    device: mediaDevices.defaultAudioOutput
    onDeviceChanged: {
        console.log("Output device changed "   device)
    }

    Component.onCompleted: {
        console.log(mediaDevices.audioOutputs)
    }
}

MediaDevices {
    id: mediaDevices
}

The 2 devices are showing:

QAudioDevice(2, Built in earpiece (IN2023), false, Output),
QAudioDevice(3, Built in speaker (IN2023), false, Output)

but I don't understand how to change it, I've tried playerOutput.setDevice() description and id but it wants a QAudioDevice (it only provides description, id and mode, the documentation for both is very vague:

This property can be used to select an output device from the QtMultimedia::MediaDevices::audioOutputs() list.

enter image description here

  • Related