Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Play a sound



  • Hello everyone,

    I'm trying to play a short sound with QSound. Everything works under GNU/Linux but no sound comes out of my speakers under Windows.
    Here is my code (very simple) :

    QSound::play(":/ressources/audio/notification.wav")
    

    and the error message displayed in the terminal :

    using null output device, none available
    

    Does somebody knows what happens ? Is there a package to install with the maintenanceTool ?

    Thank you so much !



  • @cmdEvo said in Play a sound:
    Google for qt using null output device, none available
    E.g. https://forum.qt.io/topic/31004/error-using-null-output-device-none-available
    I admit they seem to be more Linux than Windows, but might be a starting point for ideas?



  • Yes, I've already seen this topic but I didn't manage to find an answer to my issue, do you have any suggestions ?



  • Looks like your qpa audio plugin is not loaded.

    Qt comes with plugins for Windows (WinMM and WASAPI), Linux (ALSA and PulseAudio), macOS / iOS (CoreAudio), Android (OpenSL ES) and QNX.
    If no audio plugins are available, a fallback dummy backend will be used. This should print out warnings if this is the case when you try and use QAudioInput or QAudioOutput. To fix this problem, make sure the dependencies for the Qt plugins are installed on the system and reconfigure Qt (e.g. alsa-devel package on Linux), or create your own plugin with a default key to always override the dummy fallback. The easiest way to determine if you have only a dummy backend is to get a list of available audio devices.
    QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).size() = 0 (dummy backend)

    Maybe you can set QT_DEBUG_PLUGINS environment variable to 1 to check the reason.
    I remember someone once said about need to install some media package in Windows.



  • ideed, I have no available devices, but I don't know why !!



  • I have found out a solution.
    I have just copied the folder named 'plugins' from Qt\5.15.0\mingw81_64 to the release folder and it works.
    Could somebody explain me why please ? Is there an other way to load the needed plugin ?

    Source : https://forum.qt.io/topic/48800/solved-qaudiodeviceinfo-availabledevices-no-device-found-if-start-on-pc-without-qt-installed/5



  • @cmdEvo
    Oh, you didn't have the plugin folders with your application?
    Then the plugin of course won't be loaded.
    You need to copy them. That's how it works.
    But you only need plugins\audio\qtaudio_windows.dll for the audio thing.



  • Oh ok thank you for your help !!


Log in to reply