Minor cleanups and add comments to code

This commit is contained in:
Tim Bentley 2010-04-30 20:37:47 +01:00
parent 79180c7f1c
commit 22c2e4c38e
1 changed files with 41 additions and 8 deletions

View File

@ -334,7 +334,7 @@ class VideoDisplay(Phonon.VideoWidget):
self.parent = parent self.parent = parent
self.screens = screens self.screens = screens
self.hidden = False self.hidden = False
self.background = False self.message = None
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)
@ -389,16 +389,28 @@ class VideoDisplay(Phonon.VideoWidget):
self.setVisible(False) self.setVisible(False)
self.primary = True self.primary = True
def onMediaBackground(self, message): def onMediaBackground(self, message=None):
"""
Play a video triggered from the video plugin with the
file name passed in on the event.
Also triggered from the Finish event so the video will loop
if it is triggered from the plugin
"""
log.debug(u'VideoDisplay Queue new media message %s' % message)
#If not file take the stored one
if not message: if not message:
message = self.message message = self.message
log.debug(u'VideoDisplay Queue new media message %s' % message) # still no file name then stop as it was a normal video stopping
source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) if not message:
self.message = message log.debug(u'VideoDisplay Queue new media message %s' % message)
self.background = True source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message))
self._play() self.message = message
self._play()
def onMediaQueue(self, message): def onMediaQueue(self, message):
"""
Set up a video to play from the serviceitem.
"""
log.debug(u'VideoDisplay Queue new media message %s' % message) log.debug(u'VideoDisplay Queue new media message %s' % message)
file = os.path.join(message[0].get_frame_path(), file = os.path.join(message[0].get_frame_path(),
message[0].get_frame_title()) message[0].get_frame_title())
@ -406,39 +418,60 @@ class VideoDisplay(Phonon.VideoWidget):
self._play() self._play()
def onMediaPlay(self): def onMediaPlay(self):
"""
Respond to the Play button on the slide controller unless the display
has been hidden by the slidecontroller
"""
if not self.hidden: if not self.hidden:
log.debug(u'VideoDisplay Play the new media, Live ') log.debug(u'VideoDisplay Play the new media, Live ')
self._play() self._play()
def _play(self): def _play(self):
"""
We want to play the video so start it and display the screen
"""
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() self.showFullScreen()
def onMediaPause(self): def onMediaPause(self):
"""
Pause the video and refresh the screen
"""
log.debug(u'VideoDisplay Media paused by user') log.debug(u'VideoDisplay Media paused by user')
self.mediaObject.pause() self.mediaObject.pause()
self.show() self.show()
def onMediaStop(self): def onMediaStop(self):
"""
Stop the video and clean up
"""
log.debug(u'VideoDisplay Media stopped by user') log.debug(u'VideoDisplay Media stopped by user')
self.background = False
self.message = None self.message = None
self.mediaObject.stop() self.mediaObject.stop()
self.onMediaFinish() self.onMediaFinish()
def onMediaFinish(self): def onMediaFinish(self):
"""
Clean up the Object queue
"""
log.debug(u'VideoDisplay Reached end of media playlist') log.debug(u'VideoDisplay Reached end of media playlist')
self.mediaObject.clearQueue() self.mediaObject.clearQueue()
self.setVisible(False) self.setVisible(False)
def mediaHide(self): def mediaHide(self):
"""
Hide the video display
"""
self.mediaObject.pause() self.mediaObject.pause()
self.hidden = True self.hidden = True
self.setVisible(False) self.setVisible(False)
def mediaShow(self): def mediaShow(self):
"""
Show the video disaply if it was already hidden
"""
if self.hidden: if self.hidden:
self.hidden = False self.hidden = False
self._play() self._play()