How to play an .mp3 using QBuffer with Phonon in a PyQt Qt environment
- by thedax
With the code I have right now I CAN play .mp3 data from files succesfully.
However I need to play the same data using a QtCore.QBuffer (NOT from a file).
When I use the example of the docs it errors an unexpected type of QBuffer!
However...... that is what it SHOULD see, according to the docs.
But............... it throws:
TypeError: Phonon.MediaObject.setCurrentSource(Phonon.MediaSource): argument 1 has unexpected type 'QBuffer'
The code I use is (1):
someBuffer = QtCore.QBuffer()
someBuffer.writeData(TrackData)
mediaObject.setCurrentSource(someBuffer)
I also tried (2):
someBuffer = QtCore.QBuffer()
mediaObject.setCurrentSource(someBuffer)
someBuffer.writeData(TrackData)
and (3):
someBuffer = QtCore.QBuffer()
someBuffer.writeData(TrackData)
mediaObject.setCurrentSource(Phonon.MediaSource(someBuffer))
The last example (3) throws an different ERROR and wipes my Gui off screen ;-)
ASSERT: "d-connected" in file /builddir/build/BUILD/phonon-4.5.1/phonon/streaminterface.cpp, line xxxx
Notes: TrackData contains the mp3 data and IS PLAYING OK when I write it to a File and use that as a resource to mediaObject.setCurrentSource(Phonon.MediaSource())I also experimented with a QByteArray but that leads to the same "unexpected QBuffer" error. To be more precise everything I feed setCurrentSource is not accepted. Tried a string (errors an unexpected type of String), tried a QBuffer (errors an unexpected type of QBuffer), tried a QByteArray (errors an unexpected type of QByteArray).
BTW: I run Qt, PyQt on Linux.
Any ideas??