Fix up screen blanking and videos

This commit is contained in:
Tim Bentley 2010-06-28 17:48:21 +01:00
parent 5ba7febc3b
commit eafdf71e5c
1 changed files with 30 additions and 26 deletions

View File

@ -307,6 +307,7 @@ class MainDisplay(DisplayWidget):
""" """
log.debug(u'showDisplay') log.debug(u'showDisplay')
self.display_blank.setPixmap(self.transparent) self.display_blank.setPixmap(self.transparent)
#Trigger actions when display is active again
Receiver.send_message(u'maindisplay_active') Receiver.send_message(u'maindisplay_active')
def addImageWithText(self, frame): def addImageWithText(self, frame):
@ -394,28 +395,29 @@ class VideoDisplay(Phonon.VideoWidget):
self.screens = screens self.screens = screens
self.hidden = False self.hidden = False
self.message = None self.message = None
self.mediaActive = False
self.mediaObject = Phonon.MediaObject() self.mediaObject = Phonon.MediaObject()
self.setAspectRatio(aspect) self.setAspectRatio(aspect)
self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory)
Phonon.createPath(self.mediaObject, self) Phonon.createPath(self.mediaObject, self)
Phonon.createPath(self.mediaObject, self.audioObject) Phonon.createPath(self.mediaObject, self.audioObject)
flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog
# # WindowsStaysOnBottomHint is not available in QT4.4 ## # WindowsStaysOnBottomHint is not available in QT4.4
try: # try:
flags = flags | QtCore.Qt.WindowStaysOnBottomHint # flags = flags | QtCore.Qt.WindowStaysOnBottomHint
except AttributeError: # except AttributeError:
pass # pass
self.setWindowFlags(flags) self.setWindowFlags(flags)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_play'), self.onMediaPlay) QtCore.SIGNAL(u'videodisplay_play'), self.onMediaPlay)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_pause'), self.onMediaPause) QtCore.SIGNAL(u'videodisplay_pause'), self.onMediaPause)
QtCore.QObject.connect(Receiver.get_receiver(), # QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_background'), self.onMediaBackground) # QtCore.SIGNAL(u'videodisplay_background'), self.onMediaBackground)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.setup) QtCore.SIGNAL(u'config_updated'), self.setup)
QtCore.QObject.connect(self.mediaObject, QtCore.QObject.connect(self.mediaObject,
QtCore.SIGNAL(u'finished()'), self.onMediaBackground) QtCore.SIGNAL(u'finished()'), self.onMediaStop)
self.setVisible(False) self.setVisible(False)
def keyPressEvent(self, event): def keyPressEvent(self, event):
@ -454,22 +456,22 @@ class VideoDisplay(Phonon.VideoWidget):
for pth in self.outputPaths(): for pth in self.outputPaths():
disconnected = pth.disconnect() disconnected = pth.disconnect()
def onMediaBackground(self, message=None): # def onMediaBackground(self, message=None):
""" # """
Play a video triggered from the video plugin with the # Play a video triggered from the video plugin with the
file name passed in on the event. # file name passed in on the event.
Also triggered from the Finish event so the video will loop # Also triggered from the Finish event so the video will loop
if it is triggered from the plugin # if it is triggered from the plugin
""" # """
log.debug(u'VideoDisplay Queue new media message %s' % message) # log.debug(u'VideoDisplay Queue new media message %s' % message)
#If not file take the stored one # #If not file take the stored one
if not message: # if not message:
message = self.message # message = self.message
# still no file name then stop as it was a normal video stopping # # still no file name then stop as it was a normal video stopping
if message: # if message:
self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) # self.mediaObject.setCurrentSource(Phonon.MediaSource(message))
self.message = message # self.message = message
self._play() # self._play()
def onMediaQueue(self, message): def onMediaQueue(self, message):
""" """
@ -479,6 +481,7 @@ class VideoDisplay(Phonon.VideoWidget):
file = os.path.join(message.get_frame_path(), file = os.path.join(message.get_frame_path(),
message.get_frame_title()) message.get_frame_title())
self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
self.mediaActive = True
self._play() self._play()
def onMediaPlay(self): def onMediaPlay(self):
@ -497,7 +500,6 @@ class VideoDisplay(Phonon.VideoWidget):
log.debug(u'VideoDisplay _play called') log.debug(u'VideoDisplay _play called')
self.mediaObject.play() self.mediaObject.play()
self.setVisible(True) self.setVisible(True)
#self.showFullScreen()
def onMediaPause(self): def onMediaPause(self):
""" """
@ -513,6 +515,7 @@ class VideoDisplay(Phonon.VideoWidget):
""" """
log.debug(u'VideoDisplay Media stopped by user') log.debug(u'VideoDisplay Media stopped by user')
self.message = None self.message = None
self.mediaActive = False
self.mediaObject.stop() self.mediaObject.stop()
self.onMediaFinish() self.onMediaFinish()
@ -538,7 +541,8 @@ class VideoDisplay(Phonon.VideoWidget):
""" """
if self.hidden: if self.hidden:
self.hidden = False self.hidden = False
self._play() if self.mediaActive:
self._play()
class AudioPlayer(QtCore.QObject): class AudioPlayer(QtCore.QObject):
""" """