Question

i was wondering how to set a phonon player to full screen? im trying this codes.

    if not self.ui.videoPlayer.isFullScreen():
        self.ui.videoPlayer.enterFullScreen()
    else: 
        self.ui.videoPlayer.exitFullScreen()

but i keep on getting this error message

TypeError: 'sip.methoddescriptor' object is not callable

the code above works is from a sample project. the original code was

def full(self):
    if not self.videoWidget.isFullScreen():
        self.videoWidget.enterFullScreen()
    else: 
        self.videoWidget.exitFullScreen()

im recreating it in PyQT and it seems hard for me. can anyone please guide me on what im missing(having a hunch about it) or what im doing wrong?

Was it helpful?

Solution

A VideoPlayer is not the same thing as a VideoWidget.

VideoPlayer is a subclass of QWidget, so it will have an isFullScreen method - but it won't have the methods enterFullScreen and exitFullScreen, which belong to the VideoWidget class.

However, the VideoPlayer class has a videoWidget method which returns the instance of the video widget it uses, so your code example should probably be changed to:

videoWidget = self.ui.videoPlayer.videoWidget()
if videoWidget.isFullScreen():
    videoWidget.exitFullScreen()
else: 
    videoWidget.enterFullScreen()

EDIT

To provide a method for exiting fullscreen mode, set up a keyboard shortcut:

class MainWindow(QtGui.QMainWindow):
    def __init__(self)
        ...
        self.shortcutFull = QtGui.QShortcut(self)
        self.shortcutFull.setKey(QtGui.QKeySequence('F11'))
        self.shortcutFull.setContext(QtCore.Qt.ApplicationShortcut)
        self.shortcutFull.activated.connect(self.handleFullScreen)

    def handleFullScreen(self):
        videoWidget = self.ui.videoPlayer.videoWidget()
        if videoWidget.isFullScreen():
            videoWidget.exitFullScreen()
        else: 
            videoWidget.enterFullScreen()

OTHER TIPS

I think the problem is your use of self.ui.videoPlayer.isFullScreen, it's probably returning True or False, which when you use self.ui.videoPlayer.isFullScreen() is really resolving down to 'False()'.

Oddly enough, the PyQT documentation doesn't even list 'isFullScreen' as part of the available, methods/properties. However the QWidget documentation does show isFullScreen as returning a boolean.

Instead, try this:

if not self.ui.videoPlayer.isFullScreen:
    self.ui.videoPlayer.enterFullScreen()
else: 
    self.ui.videoPlayer.exitFullScreen()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top