Qt Forum

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

    Solved Playing mp3s from a qrc .py file using PyQt5.QtMultimedia?

    Qt for Python
    2
    6
    213
    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.
    • S
      Shawn Driscoll last edited by

      With PyQt4, I was able to use Phonon to play ':/sound/track1.mp3' stored inside of a qrc .py file made from pyrcc4. Is something like this still do-able using QtMultimedia from PyQt5? Or does QtMultimedia only work for localfilename mp3s?

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

        It's not a local file. Use something like:

        QMediaContent(QUrl("qrc:/sound/track1.mp3"))
        

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

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

          Hi,

          IIRC, QtMultimedia will copy the file to a temporary file so the system can play if it can't do otherwise so it should work.

          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
          • S
            Shawn Driscoll last edited by

            I get:

            DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x8007007b (The filename, directory name, or volume label syntax is incorrect.)

            When I try it.
            I'm using:

            QMediaContent(QUrl.fromLocalFile(':/sound/track1.mp3'))
            

            And I'm beginning to think that I shouldn't be using QUrl for my content path.

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

              It's not a local file. Use something like:

              QMediaContent(QUrl("qrc:/sound/track1.mp3"))
              

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

              S 1 Reply Last reply Reply Quote 1
              • S
                Shawn Driscoll @SGaist last edited by

                @SGaist Cool. It's playing now. Thank you.

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

                  You're welcome !

                  Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

                  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