Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Playing mp3s from a qrc .py file using PyQt5.QtMultimedia?
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Solved Qt for Python
6 Posts 2 Posters 588 Views
  • 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 Offline
    S Offline
    Shawn Driscoll
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      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
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        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
        0
        • S Offline
          S Offline
          Shawn Driscoll
          wrote on last edited by
          #3

          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
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            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
            1
            • SGaistS SGaist

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

              QMediaContent(QUrl("qrc:/sound/track1.mp3"))
              
              S Offline
              S Offline
              Shawn Driscoll
              wrote on last edited by
              #5

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

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved