forked from openlp/openlp
Clean up video class
This commit is contained in:
parent
d96126ee55
commit
5a311c6f77
@ -138,7 +138,7 @@ class OpenLP(QtGui.QApplication):
|
|||||||
log.info(u'Screen %d found with resolution %s',
|
log.info(u'Screen %d found with resolution %s',
|
||||||
screen, self.desktop().availableGeometry(screen))
|
screen, self.desktop().availableGeometry(screen))
|
||||||
# start the main app window
|
# start the main app window
|
||||||
self.mainWindow = MainWindow(screens, app_version, self)
|
self.mainWindow = MainWindow(screens, app_version)
|
||||||
self.mainWindow.show()
|
self.mainWindow.show()
|
||||||
if show_splash:
|
if show_splash:
|
||||||
# now kill the splashscreen
|
# now kill the splashscreen
|
||||||
|
@ -296,34 +296,15 @@ class MainDisplay(DisplayWidget):
|
|||||||
elif self.display_frame:
|
elif self.display_frame:
|
||||||
self.frameView(self.display_frame)
|
self.frameView(self.display_frame)
|
||||||
|
|
||||||
class VideoWidget(QtGui.QWidget):
|
|
||||||
"""
|
|
||||||
Customised version of QTableWidget which can respond to keyboard
|
|
||||||
events.
|
|
||||||
"""
|
|
||||||
log.info(u'MainDisplay loaded')
|
|
||||||
|
|
||||||
def __init__(self, parent=None, name=None):
|
class VideoDisplay(Phonon.VideoWidget):
|
||||||
QtGui.QWidget.__init__(self, None)
|
|
||||||
self.parent = parent
|
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
|
||||||
if type(event) == QtGui.QKeyEvent:
|
|
||||||
#here accept the event and do something
|
|
||||||
if event.key() == QtCore.Qt.Key_Escape:
|
|
||||||
self.resetDisplay()
|
|
||||||
event.accept()
|
|
||||||
event.ignore()
|
|
||||||
else:
|
|
||||||
event.ignore()
|
|
||||||
|
|
||||||
class VideoDisplay(VideoWidget):
|
|
||||||
"""
|
"""
|
||||||
This is the form that is used to display videos on the projector.
|
This is the form that is used to display videos on the projector.
|
||||||
"""
|
"""
|
||||||
log.info(u'VideoDisplay Loaded')
|
log.info(u'VideoDisplay Loaded')
|
||||||
|
|
||||||
def __init__(self, parent, screens):
|
def __init__(self, parent, screens,
|
||||||
|
aspect=Phonon.VideoWidget.AspectRatioWidget):
|
||||||
"""
|
"""
|
||||||
The constructor for the display form.
|
The constructor for the display form.
|
||||||
|
|
||||||
@ -334,17 +315,15 @@ class VideoDisplay(VideoWidget):
|
|||||||
The list of screens.
|
The list of screens.
|
||||||
"""
|
"""
|
||||||
log.debug(u'VideoDisplay Initilisation started')
|
log.debug(u'VideoDisplay Initilisation started')
|
||||||
VideoWidget.__init__(self, parent)
|
Phonon.VideoWidget.__init__(self)
|
||||||
self.setWindowTitle(u'OpenLP Video Display')
|
self.setWindowTitle(u'OpenLP Video Display')
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.screens = screens
|
self.screens = screens
|
||||||
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
self.mediaObject = Phonon.MediaObject()
|
||||||
self.mediaObject = Phonon.MediaObject(self)
|
self.setAspectRatio(aspect)
|
||||||
self.video = Phonon.VideoWidget(parent)
|
self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory)
|
||||||
self.video.setVisible(False)
|
Phonon.createPath(self.mediaObject, self)
|
||||||
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
|
Phonon.createPath(self.mediaObject, self.audioObject)
|
||||||
Phonon.createPath(self.mediaObject, self.video)
|
|
||||||
Phonon.createPath(self.mediaObject, self.audio)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'media_start'), self.onMediaQueue)
|
QtCore.SIGNAL(u'media_start'), self.onMediaQueue)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
@ -356,6 +335,16 @@ class VideoDisplay(VideoWidget):
|
|||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'update_config'), self.setup)
|
QtCore.SIGNAL(u'update_config'), self.setup)
|
||||||
|
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
if type(event) == QtGui.QKeyEvent:
|
||||||
|
#here accept the event and do something
|
||||||
|
if event.key() == QtCore.Qt.Key_Escape:
|
||||||
|
self.onMediaStop()
|
||||||
|
event.accept()
|
||||||
|
event.ignore()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""
|
"""
|
||||||
Sets up the screen on a particular screen.
|
Sets up the screen on a particular screen.
|
||||||
@ -366,7 +355,13 @@ class VideoDisplay(VideoWidget):
|
|||||||
self.screen = self.screens.current
|
self.screen = self.screens.current
|
||||||
#Sort out screen locations and sizes
|
#Sort out screen locations and sizes
|
||||||
self.setGeometry(self.screen[u'size'])
|
self.setGeometry(self.screen[u'size'])
|
||||||
self.video.setGeometry(self.screen[u'size'])
|
# To display or not to display?
|
||||||
|
if not self.screen[u'primary']:
|
||||||
|
self.showFullScreen()
|
||||||
|
self.primary = False
|
||||||
|
else:
|
||||||
|
self.setVisible(False)
|
||||||
|
self.primary = True
|
||||||
|
|
||||||
def onMediaQueue(self, message):
|
def onMediaQueue(self, message):
|
||||||
log.debug(u'VideoDisplay Queue new media message %s' % message)
|
log.debug(u'VideoDisplay Queue new media message %s' % message)
|
||||||
@ -376,11 +371,9 @@ class VideoDisplay(VideoWidget):
|
|||||||
|
|
||||||
def onMediaPlay(self):
|
def onMediaPlay(self):
|
||||||
log.debug(u'VideoDisplay Play the new media, Live ')
|
log.debug(u'VideoDisplay Play the new media, Live ')
|
||||||
self.setWindowState(QtCore.Qt.WindowMinimized)
|
|
||||||
self.video.setFullScreen(True)
|
|
||||||
self.mediaObject.play()
|
self.mediaObject.play()
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
self.show()
|
self.showFullScreen()
|
||||||
|
|
||||||
def onMediaPause(self):
|
def onMediaPause(self):
|
||||||
log.debug(u'VideoDisplay Media paused by user')
|
log.debug(u'VideoDisplay Media paused by user')
|
||||||
@ -391,11 +384,8 @@ class VideoDisplay(VideoWidget):
|
|||||||
log.debug(u'VideoDisplay Media stopped by user')
|
log.debug(u'VideoDisplay Media stopped by user')
|
||||||
self.mediaObject.stop()
|
self.mediaObject.stop()
|
||||||
self.onMediaFinish()
|
self.onMediaFinish()
|
||||||
self.show()
|
|
||||||
|
|
||||||
def onMediaFinish(self):
|
def onMediaFinish(self):
|
||||||
log.debug(u'VideoDisplay Reached end of media playlist')
|
log.debug(u'VideoDisplay Reached end of media playlist')
|
||||||
self.mediaObject.stop()
|
|
||||||
self.mediaObject.clearQueue()
|
self.mediaObject.clearQueue()
|
||||||
self.video.setVisible(False)
|
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
|
@ -431,7 +431,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
log.info(u'MainWindow loaded')
|
log.info(u'MainWindow loaded')
|
||||||
|
|
||||||
def __init__(self, screens, applicationVersion, application):
|
def __init__(self, screens, applicationVersion):
|
||||||
"""
|
"""
|
||||||
This constructor sets up the interface, the various managers, and the
|
This constructor sets up the interface, the various managers, and the
|
||||||
plugins.
|
plugins.
|
||||||
|
Loading…
Reference in New Issue
Block a user