Reference tidy up

This commit is contained in:
Tim Bentley 2012-10-29 17:25:08 +00:00
parent a106244aba
commit a1bd9013cb
3 changed files with 81 additions and 74 deletions

View File

@ -370,6 +370,8 @@ class MediaController(object):
log.debug(u'video')
isValid = False
controller = self.displayControllers[source]
print "video"
print source, controller
# stop running videos
self.media_reset(controller)
controller.media_info = MediaInfo()
@ -381,13 +383,9 @@ class MediaController(object):
controller.media_info.is_background = False
controller.media_info.file_info = \
QtCore.QFileInfo(serviceItem.get_filename())
display = None
display = self._define_display(controller)
if controller.isLive:
##if controller.previewDisplay:
# display = controller.previewDisplay
# isValid = self._check_file_type(controller, display,
# serviceItem)
display = controller.display
#display = controller.display
isValid = self._check_file_type(controller, display, serviceItem)
display.override[u'theme'] = u''
display.override[u'video'] = True
@ -400,7 +398,7 @@ class MediaController(object):
display.serviceItem.start_time
controller.media_info.end_time = serviceItem.end_time
elif controller.previewDisplay:
display = controller.previewDisplay
#display = controller.previewDisplay
isValid = self._check_file_type(controller, display, serviceItem)
if not isValid:
# Media could not be loaded correctly
@ -481,7 +479,7 @@ class MediaController(object):
``serviceItem``
The ServiceItem containing the details to be played.
"""
print display
print "_check_file_type", controller,display
usedPlayers = get_media_players()[0]
if serviceItem.title != u'Automatic':
usedPlayers = [serviceItem.title.lower()]
@ -532,11 +530,11 @@ class MediaController(object):
Responds to the request to play a loaded video
``controller``
First element is the controller which should be used
The controller to be played
"""
log.debug(u'media_play')
for display in self.curDisplayMediaPlayer.keys():
if display.controller == controller:
display = self._define_display(controller)
if not self.curDisplayMediaPlayer[display].play(display):
return False
if status:
@ -571,12 +569,11 @@ class MediaController(object):
"""
Responds to the request to pause a loaded video
``msg``
First element is the controller which should be used
``controller``
The Controller to be paused
"""
log.debug(u'media_pause')
for display in self.curDisplayMediaPlayer.keys():
if display.controller == controller:
display = self._define_display(controller)
self.curDisplayMediaPlayer[display].pause(display)
controller.mediabar.actions[u'playbackPlay']\
.setVisible(True)
@ -599,12 +596,12 @@ class MediaController(object):
"""
Responds to the request to stop a loaded video
``msg``
First element is the controller which should be used
``controller``
The controller that needs to be stopped
"""
log.debug(u'media_stop')
for display in self.curDisplayMediaPlayer.keys():
if display.controller == controller:
display = self._define_display(controller)
if display in self.curDisplayMediaPlayer:
display.frame.evaluateJavaScript(u'show_blank("black");')
self.curDisplayMediaPlayer[display].stop(display)
self.curDisplayMediaPlayer[display].set_visible(display, False)
@ -626,8 +623,7 @@ class MediaController(object):
controller = msg[0]
vol = msg[1][0]
log.debug(u'media_volume %d' % vol)
for display in self.curDisplayMediaPlayer.keys():
if display.controller == controller:
display = self._define_display(controller)
self.curDisplayMediaPlayer[display].volume(display, vol)
def media_seek(self, msg):
@ -651,8 +647,8 @@ class MediaController(object):
"""
log.debug(u'media_reset')
self.set_controls_visible(controller, False)
for display in self.curDisplayMediaPlayer.keys():
if display.controller == controller:
display = self._define_display(controller)
if display in self.curDisplayMediaPlayer:
display.override = {}
self.curDisplayMediaPlayer[display].reset(display)
self.curDisplayMediaPlayer[display].set_visible(display, False)
@ -726,3 +722,11 @@ class MediaController(object):
self.timer.stop()
for controller in self.controller:
self.media_reset(controller)
def _define_display(self, controller):
"""
Extract the correct display for a given controller
"""
if controller.isLive:
return controller.display
return controller.previewDisplay

View File

@ -175,9 +175,12 @@ class VlcPlayer(MediaPlayer):
display.vlcWidget.resize(display.size())
def play(self, display):
print "vlc play",display
controller = display.controller
print controller
start_time = 0
if controller.media_info.start_time > 0:
if self.state != MediaState.Paused and\
controller.media_info.start_time > 0:
start_time = controller.media_info.start_time
display.vlcMediaPlayer.play()
if not self.media_state_wait(display, vlc.State.Playing):

View File

@ -64,22 +64,22 @@ class MediaMediaItem(MediaManagerItem):
self.singleServiceItem = False
self.hasSearch = True
self.mediaObject = None
self.mediaController = DisplayController(parent)
self.mediaController.controllerLayout = QtGui.QVBoxLayout()
self.plugin.mediaController.register_controller(self.mediaController,
self.displayController = DisplayController(parent)
self.displayController.controllerLayout = QtGui.QVBoxLayout()
self.plugin.mediaController.register_controller(self.displayController,
DisplayControllerType.Plugin,
self.mediaController.controllerLayout)
self.plugin.mediaController.set_controls_visible(self.mediaController,
self.displayController.controllerLayout)
self.plugin.mediaController.set_controls_visible(self.displayController,
False)
self.mediaController.previewDisplay = Display(self.mediaController,
False, self.mediaController)
self.mediaController.previewDisplay.setGeometry(
self.displayController.previewDisplay = Display(self.displayController,
False, self.displayController)
self.displayController.previewDisplay.setGeometry(
QtCore.QRect(0, 0, 300, 300))
self.mediaController.previewDisplay.screen = \
{u'size':self.mediaController.previewDisplay.geometry()}
self.mediaController.previewDisplay.setup()
self.displayController.previewDisplay.screen = \
{u'size':self.displayController.previewDisplay.geometry()}
self.displayController.previewDisplay.setup()
self.plugin.mediaController.setup_display(
self.mediaController.previewDisplay, False)
self.displayController.previewDisplay, False)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'video_background_replaced'),
self.videobackgroundReplaced)