[PyQt] floating player controls (like new Quicktime)?

vamp kurt.barlow at gmail.com
Wed Jun 17 22:28:32 BST 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_())



-- 
View this message in context: http://www.nabble.com/floating-player-controls-%28like-new-Quicktime%29--tp24082432p24082432.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list