I'm definitely in need of your help guys.. As in really.
My laptop has been stolen and I didn't have a backup of my
pyqt phonon video player that I made a year ago. I forgot how and what to do to recreate it.
I only know some key things to do for it to work. So please help me out.
From what i can remember I need to
If there's someone out there who have a working sample python videoplayer, can you please share it with me?
I'm trying it right now and my sample doesn't work at all
from PyQt4.phonon import Phonon
media_source = phonon.Phonon.MediaSource("C:\\Sample.avi")
self.ui.videoPlayer.load(media_source)
self.ui.videoPlayer.play()
Please help me. And thank you very much to you guys.
I'm using python 2.6 and qt version 4.9. Now I'm coding on a virtual box windows XP
EDIT: got a following sample with this problem but.. having this error when loading a file.
"The Operation Cannot Be Performed Because the Pins Are Not Connected"
This maybe because I'm using a virtual box in Ubuntu?
Don't forget to show()
the videoplayer. For the rest, in my experience Phonon often has trouble finding the codecs needed to play videos on Windows. Installing K-Lite codec pack might work in that situation.
Here's a self-contained example that does work for me (Windows Vista32, Python 2.6.5, PyQt 4.7.3).
import sys
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon
app = QtGui.QApplication(sys.argv)
vp = Phonon.VideoPlayer()
media = Phonon.MediaSource('C:\\video.mp4')
vp.load(media)
vp.play()
vp.show()
sys.exit(app.exec_())
Edit:
Multiple people have recently commented that the above code no longer gives the desired behavior. I haven't worked with PyQt in ages, but I suspect that one of the updates might have changed Phonon functionality.
According to the commenters, vp.show()
now needs to be called before Phonon.MediaSource()
, i.e.:
...
vp = Phonon.VideoPlayer()
vp.show()
media = Phonon.MediaSource('C:\\video.mp4')
vp.load(media)
vp.play()
sys.exit(app.exec_())