Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved QSound only works on my development machine

    General and Desktop
    qsound
    4
    5
    1643
    Loading More Posts
    • 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.
    • A
      alan.lenton last edited by

      I can get QSound to play on my development kit (Qt5.4, Windows7, VS2013+QtPlugin) using this code:

      SoundFx::SoundFx(QObject *parent) : QObject(parent)
      {
      sound_dir = QString::fromStdString(FedTerm::base_dir) + "/sounds/";
      }

      void SoundFx::Play(int sound)
      {
      switch(sound)
      {
      case ALERT: QSound::play(QDir::toNativeSeparators(sound_dir + "alert.wav")); break;
      case FRIENDS: QSound::play(QDir::toNativeSeparators(sound_dir + "friends.wav")); break;
      }
      }

      However, on other computers, for some reason I can't fathom, it just doesn't play. The directory is correct, and there is no error message. I the multimedia library is present. I'm sure I'm missing something obvious, but I have no idea what.

      Can anyone point me in the right direction?

      Many thanks,

      Alan

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        @alan.lenton said:
        Hi
        Are you 100% sure that
        FedTerm::base_dir
        is pointing to the correct folder on the "other" machines?

        Also if u run the .exe in the deploy folder on your own machine,
        does it just work?

        1 Reply Last reply Reply Quote 0
        • VRonin
          VRonin last edited by

          On windows you have to deploy the audio plugin qtaudio_windows.dll and qtmedia_audioengine.dll

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          A 1 Reply Last reply Reply Quote 1
          • A
            alan.lenton @VRonin last edited by

            @VRonin

            Thank you that worked - once I'd figured out the directories to put them in!

            There's nothing in the documentation for QSound that indicates you need plugins. It would be nice if those bits of the library that need plugins told you which ones it needs. For instance:
            Header: #include <QSound>
            qmake: QT += multimedia
            Plugins: qtaudio_windows.dll, qmedia_audioengine.dll

            By the way, I happen to think that in general,the Qt documentation is very good :)

            alan

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Hi,

              That's what usually windeployqt does for you :)

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post