Qt Forum

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

    Playing a SoundEffect from a QRC

    QML and Qt Quick
    4
    7
    4123
    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.
    • J
      jonricha last edited by

      Hi,

      I'm trying, with Qt Mobility 1.1.1, to play a sound file from a QRC. All of my QML files are loading properly, so there shouldn't be an issue with the import paths. I try to load a wav file like this:

      SoundEffect {
          id: a
          source: "hi.wav"
      }
      

      If I do this, I can see that the status is 3 if I try to load from a QRC (and the wav won't play), but it is 2 if I leave my code/resources out of the qrc (and it runs just fine). Is there any special way of defining the source within a qrc? I've tried source: "qrc:hi.wav", source: "qrc:/hi.wav", source: "qrc://hi.wav", but nothing worked. Any help would be appreciated.

      Thanks

      1 Reply Last reply Reply Quote 0
      • T
        tobias.hunger last edited by

        Did you try ":/hi.wav"? That is what I would use in C++.

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

          That should not be needed, should it? I mean: paths are supposed to be relative. For other QML files, you also just reference them by relative path. Why would a sound file for a sound effect be any different? The only time I use the :/ notation with QML, is when I load the main QML file in my QDeclarativeView...

          1 Reply Last reply Reply Quote 0
          • J
            jonricha last edited by

            Yeah, I tried ":/hi.wav" also and that didn't work either. I'm guessing there's a bug loading a wav file from a qrc, but I was just checking if there was something that I was doing wrong first. I agree with Andre that is "should" be just "hi.wav" as paths are supposed to be relative...

            1 Reply Last reply Reply Quote 0
            • J
              jonricha last edited by

              Argh, I just found this old bug from 4.6.2:

              http://bugreports.qt.nokia.com/browse/QTBUG-9253

              I don't really like the answer though ;-)

              1 Reply Last reply Reply Quote 0
              • M
                moo1 last edited by

                I don't know if this issue goes away, but there seems to be a plan to use something else than QSound. See this "QTMOBILITY-864":http://bugreports.qt.nokia.com/browse/QTMOBILITY-864

                1 Reply Last reply Reply Quote 0
                • J
                  jonricha last edited by

                  Thanks for that moo1, you're right that it "might" go away if they're moving away from QSound. I added my vote for that bug just in case ;-)

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