[PyQt] Newbie question - Quicktime
David Boddie
david at boddie.org.uk
Wed Jul 7 00:38:28 BST 2010
On Wed Jul 7 00:13:43 BST 2010, Hugo Léveillé wrote:
> Id like to have some pointer on how, if possible, to add a quicktime
> movie in pyqt.
>
> I guess I have to add it to a label ?
> How to you add it ( QtGui.QMovie ? )
QMovie is an ancient class that basically plays animated GIF files and
some MNG files. To play video streams and files, you need to look at the
classes in the Phonon module.
PyQt doesn't appear to have any Phonon examples written in Python and, from
memory, I think the only one supplied with Qt is actually a demo.
This code came from an example I wrote for PyCon Italia last year:
class Player(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.player = Phonon.VideoPlayer(Phonon.VideoCategory)
urlLabel = QLabel(self.tr("&Location:"))
self.urlEdit = QLineEdit()
urlLabel.setBuddy(self.urlEdit)
self.playButton = QPushButton(self.tr("&Play/Stop"))
self.connect(self.urlEdit, SIGNAL("returnPressed()"),
self.playButton, SLOT("animateClick()"))
self.connect(self.playButton, SIGNAL("clicked()"),
self.play)
layout = QGridLayout(self)
layout.addWidget(self.player, 0, 0, 2, 3)
layout.addWidget(urlLabel, 2, 0)
layout.addWidget(self.urlEdit, 2, 1)
layout.addWidget(self.playButton, 2, 2)
def play(self):
if self.player.isPlaying():
self.player.stop()
else:
url = QUrl(self.urlEdit.text())
self.player.play(Phonon.MediaSource(url))
I hope you find it useful.
David
More information about the PyQt
mailing list