Playing mp3s from a qrc .py file using PyQt5.QtMultimedia?
-
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?
-
It's not a local file. Use something like:
QMediaContent(QUrl("qrc:/sound/track1.mp3"))
-
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.
-
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.
-
It's not a local file. Use something like:
QMediaContent(QUrl("qrc:/sound/track1.mp3"))
-
@SGaist Cool. It's playing now. Thank you.
-
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 :-)