forked from openlp/openlp
Fix player selection and simplify media_length
This commit is contained in:
parent
8e5dafb715
commit
a997bfa001
@ -232,7 +232,7 @@ class MediaController(object):
|
|||||||
``controller_panel``
|
``controller_panel``
|
||||||
The controllers toolbar where the widgets reside
|
The controllers toolbar where the widgets reside
|
||||||
"""
|
"""
|
||||||
#self.displayControllers[source] = controller
|
self.displayControllers[source] = controller
|
||||||
self.controller.append(controller)
|
self.controller.append(controller)
|
||||||
self.setup_generic_controls(controller, control_panel)
|
self.setup_generic_controls(controller, control_panel)
|
||||||
|
|
||||||
@ -383,9 +383,9 @@ class MediaController(object):
|
|||||||
if controller.isLive:
|
if controller.isLive:
|
||||||
if controller.previewDisplay:
|
if controller.previewDisplay:
|
||||||
display = controller.previewDisplay
|
display = controller.previewDisplay
|
||||||
isValid = self._check_file_type(controller, display)
|
isValid = self._check_file_type(controller, display, serviceItem)
|
||||||
display = controller.display
|
display = controller.display
|
||||||
isValid = self._check_file_type(controller, display)
|
isValid = self._check_file_type(controller, display, serviceItem)
|
||||||
display.override[u'theme'] = u''
|
display.override[u'theme'] = u''
|
||||||
display.override[u'video'] = True
|
display.override[u'video'] = True
|
||||||
if controller.media_info.is_background:
|
if controller.media_info.is_background:
|
||||||
@ -398,7 +398,7 @@ class MediaController(object):
|
|||||||
controller.media_info.end_time = serviceItem.end_time
|
controller.media_info.end_time = serviceItem.end_time
|
||||||
elif controller.previewDisplay:
|
elif controller.previewDisplay:
|
||||||
display = controller.previewDisplay
|
display = controller.previewDisplay
|
||||||
isValid = self._check_file_type(controller, display)
|
isValid = self._check_file_type(controller, display, serviceItem)
|
||||||
if not isValid:
|
if not isValid:
|
||||||
# Media could not be loaded correctly
|
# Media could not be loaded correctly
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
@ -434,16 +434,14 @@ class MediaController(object):
|
|||||||
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def media_length(self, controller, serviceItem):
|
def media_length(self, serviceItem):
|
||||||
"""
|
"""
|
||||||
Loads and starts a media item to obtain the media length
|
Loads and starts a media item to obtain the media length
|
||||||
|
|
||||||
``controller``
|
|
||||||
First element is the controller which should be used
|
|
||||||
|
|
||||||
``serviceItem``
|
``serviceItem``
|
||||||
The ServiceItem containing the details to be played.
|
The ServiceItem containing the details to be played.
|
||||||
"""
|
"""
|
||||||
|
controller = self.displayControllers[DisplayControllerType.Plugin]
|
||||||
log.debug(u'media_length')
|
log.debug(u'media_length')
|
||||||
# stop running videos
|
# stop running videos
|
||||||
self.media_reset(controller)
|
self.media_reset(controller)
|
||||||
@ -452,7 +450,7 @@ class MediaController(object):
|
|||||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem
|
controller.media_info.file_info = QtCore.QFileInfo(serviceItem
|
||||||
.get_filename())
|
.get_filename())
|
||||||
display = controller.previewDisplay
|
display = controller.previewDisplay
|
||||||
if not self._check_file_type(controller, display):
|
if not self._check_file_type(controller, display, serviceItem):
|
||||||
# Media could not be loaded correctly
|
# Media could not be loaded correctly
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||||
@ -470,7 +468,7 @@ class MediaController(object):
|
|||||||
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _check_file_type(self, controller, display):
|
def _check_file_type(self, controller, display, serviceItem):
|
||||||
"""
|
"""
|
||||||
Select the correct media Player type from the prioritized Player list
|
Select the correct media Player type from the prioritized Player list
|
||||||
|
|
||||||
@ -480,9 +478,9 @@ class MediaController(object):
|
|||||||
``serviceItem``
|
``serviceItem``
|
||||||
The ServiceItem containing the details to be played.
|
The ServiceItem containing the details to be played.
|
||||||
"""
|
"""
|
||||||
usedPlayers, overriddenPlayer = get_media_players()
|
usedPlayers = get_media_players()[0]
|
||||||
if overriddenPlayer and overriddenPlayer != u'auto':
|
if serviceItem.title != u'Automatic':
|
||||||
usedPlayers = [overriddenPlayer]
|
usedPlayers = [serviceItem.title.lower()]
|
||||||
if controller.media_info.file_info.isFile():
|
if controller.media_info.file_info.isFile():
|
||||||
suffix = u'*.%s' % \
|
suffix = u'*.%s' % \
|
||||||
controller.media_info.file_info.suffix().toLower()
|
controller.media_info.file_info.suffix().toLower()
|
||||||
|
@ -208,8 +208,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
# Only get start and end times if going to a service
|
# Only get start and end times if going to a service
|
||||||
if context == ServiceItemContext.Service:
|
if context == ServiceItemContext.Service:
|
||||||
# Start media and obtain the length
|
# Start media and obtain the length
|
||||||
if not self.plugin.mediaController.media_length(
|
if not self.plugin.mediaController.media_length(service_item):
|
||||||
self.mediaController, service_item):
|
|
||||||
return False
|
return False
|
||||||
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
|
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
|
||||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||||
|
Loading…
Reference in New Issue
Block a user