[Qt-interest] floating player controls (like new Quicktime)?
Kurt Barlow
kurt.barlow at gmail.com
Wed Jun 17 23:17:04 CEST 2009
Hello,
After watching the apple keynote I thought I would try to duplicate the
floating video player control they are using in the new version of
Quicktime.
A semi-transparent widget on top of a window works fine but I have problems
when it comes to placing it over top of a playing video.
Ultimately, I would like to have a widget with a semi-transparent background
that I can add controls to (labels with images) sitting on top of the
playing video (without any flicker).
Its just the semi-transparent widget on top of the playing video I need help
with. Is it possible do you think? Here is a simple example of my problem
(in pyqt 4.5 using qt 4.5, python 2.6 ), thanks ...
import sys, time
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon
app = QtGui.QApplication(sys.argv)
screen = QtGui.QDesktopWidget().screenGeometry(-1)
screenWidth = screen.width()
screenHeight = screen.height()
class PlayControl(QtGui.QWidget):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
def paintEvent(self, event):
painter = QtGui.QPainter(self)
# alpha color to paint onto the widget
col = QtGui.QColor(0,0,0,125)
#fill the rectangle
painter.fillRect(0, 0, 200, 200, col)
class VideoPlayer(Phonon.VideoPlayer):
def __init__(self, parent=None):
Phonon.VideoPlayer.__init__(self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.resize(screenWidth, screenHeight)
self.move(0,0)
self.load(Phonon.MediaSource("c:/temp/FirefoxInMotion.ogv"))
self.videoWidget().setScaleMode(1)
pc = PlayControl(self)
pc.setGeometry(0,50,200,200)
pc.show()
class GenericWidget(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.resize(screenWidth, screenHeight)
self.move(0,0)
pc = PlayControl(self)
pc.setGeometry(0,50,200,200)
pc.show()
# working fine
gw = GenericWidget()
gw.show()
# not working
'''
vp = VideoPlayer()
vp.show()
vp.play()
'''
sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090617/8e1297ef/attachment.html
More information about the Qt-interest-old
mailing list