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

Brian Kelley kelley at eyesopen.com
Wed Jun 17 22:51:03 BST 2009


You are running into problems with the operating system's compositing layer.

I have had the same problem with transparent over OpenGL.  What you might try, is to move your player widget into a QGraphicsWidget and play it in a QGraphicsView.  If this works, you can make your floating widgets on the canvas.

I'm not sure if phonon widgets can be played in this way, but they should.

Good luck!

Brian

On 6/17/09 5:28 PM, "vamp" <kurt.barlow at gmail.com> wrote:



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.

_______________________________________________
PyQt mailing list    PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090617/d353eb00/attachment-0001.html


More information about the PyQt mailing list