forked from openlp/openlp
Refactor video length
This commit is contained in:
parent
6ef5fa88d2
commit
1df6934bda
@ -356,6 +356,37 @@ 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, service_item):
|
||||||
|
"""
|
||||||
|
Loads and starts a video to run with the option of sound
|
||||||
|
"""
|
||||||
|
print controller
|
||||||
|
log.debug(u'media_length')
|
||||||
|
# stop running videos
|
||||||
|
self.video_reset(controller)
|
||||||
|
controller.media_info = MediaInfo()
|
||||||
|
controller.media_info.volume = controller.volumeSlider.value()
|
||||||
|
controller.media_info.file_info = QtCore.QFileInfo(service_item
|
||||||
|
.get_filename())
|
||||||
|
display = controller.previewDisplay
|
||||||
|
if not self.check_file_type(controller, display):
|
||||||
|
# Media could not be loaded correctly
|
||||||
|
critical_error_message_box(
|
||||||
|
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||||
|
unicode(translate('MediaPlugin.MediaItem',
|
||||||
|
'Unsupported File')))
|
||||||
|
return False
|
||||||
|
# set a black background by default no theme is needed.
|
||||||
|
if not self.video_play([controller]):
|
||||||
|
critical_error_message_box(
|
||||||
|
translate('MediaPlugin.MediaItem', 'Unsupported File'),
|
||||||
|
unicode(translate('MediaPlugin.MediaItem',
|
||||||
|
'Unsupported File')))
|
||||||
|
return False
|
||||||
|
self.video_stop([controller])
|
||||||
|
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
||||||
|
return True
|
||||||
|
|
||||||
def check_file_type(self, controller, display):
|
def check_file_type(self, controller, display):
|
||||||
"""
|
"""
|
||||||
Select the correct media Player type from the prioritized Player list
|
Select the correct media Player type from the prioritized Player list
|
||||||
|
@ -35,6 +35,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
|
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
|
||||||
SettingsManager, translate, check_item_selected, Receiver, MediaType, \
|
SettingsManager, translate, check_item_selected, Receiver, MediaType, \
|
||||||
ServiceItem, build_html
|
ServiceItem, build_html
|
||||||
|
from openlp.core.lib.settings import Settings
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||||
create_horizontal_adjusting_combo_box
|
create_horizontal_adjusting_combo_box
|
||||||
from openlp.core.ui import Controller, Display
|
from openlp.core.ui import Controller, Display
|
||||||
@ -63,11 +64,11 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.mediaObject = None
|
self.mediaObject = None
|
||||||
self.mediaController = Controller(parent)
|
self.mediaController = Controller(parent)
|
||||||
self.mediaController.controllerLayout = QtGui.QVBoxLayout()
|
self.mediaController.controllerLayout = QtGui.QVBoxLayout()
|
||||||
self.plugin.mediaController.add_controller_items(self.mediaController, \
|
self.plugin.mediaController.add_controller_items(self.mediaController,
|
||||||
self.mediaController.controllerLayout)
|
self.mediaController.controllerLayout)
|
||||||
self.plugin.mediaController.set_controls_visible(self.mediaController, \
|
self.plugin.mediaController.set_controls_visible(self.mediaController,
|
||||||
False)
|
False)
|
||||||
self.mediaController.previewDisplay = Display(self.mediaController, \
|
self.mediaController.previewDisplay = Display(self.mediaController,
|
||||||
False, self.mediaController)
|
False, self.mediaController)
|
||||||
self.mediaController.previewDisplay.setGeometry(
|
self.mediaController.previewDisplay.setGeometry(
|
||||||
QtCore.QRect(0, 0, 300, 300))
|
QtCore.QRect(0, 0, 300, 300))
|
||||||
@ -75,11 +76,11 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
{u'size':self.mediaController.previewDisplay.geometry()}
|
{u'size':self.mediaController.previewDisplay.geometry()}
|
||||||
self.mediaController.previewDisplay.setup()
|
self.mediaController.previewDisplay.setup()
|
||||||
serviceItem = ServiceItem()
|
serviceItem = ServiceItem()
|
||||||
self.mediaController.previewDisplay.webView.setHtml(build_html( \
|
self.mediaController.previewDisplay.webView.setHtml(build_html(
|
||||||
serviceItem, self.mediaController.previewDisplay.screen, None, \
|
serviceItem, self.mediaController.previewDisplay.screen, None,
|
||||||
False, None))
|
False, None))
|
||||||
self.mediaController.previewDisplay.setup()
|
self.mediaController.previewDisplay.setup()
|
||||||
self.plugin.mediaController.setup_display( \
|
self.plugin.mediaController.setup_display(
|
||||||
self.mediaController.previewDisplay)
|
self.mediaController.previewDisplay)
|
||||||
self.mediaController.previewDisplay.hide()
|
self.mediaController.previewDisplay.hide()
|
||||||
|
|
||||||
@ -154,7 +155,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
Called to reset the Live background with the media selected,
|
Called to reset the Live background with the media selected,
|
||||||
"""
|
"""
|
||||||
self.plugin.liveController.mediaController.video_reset( \
|
self.plugin.liveController.mediaController.video_reset(
|
||||||
self.plugin.liveController)
|
self.plugin.liveController)
|
||||||
self.resetAction.setVisible(False)
|
self.resetAction.setVisible(False)
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
if self.plugin.liveController.mediaController.video( \
|
if self.plugin.liveController.mediaController.video(
|
||||||
self.plugin.liveController, filename, True, True):
|
self.plugin.liveController, filename, True, True):
|
||||||
self.resetAction.setVisible(True)
|
self.resetAction.setVisible(True)
|
||||||
else:
|
else:
|
||||||
@ -203,24 +204,24 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
'The file %s no longer exists.')) % filename)
|
'The file %s no longer exists.')) % filename)
|
||||||
return False
|
return False
|
||||||
self.mediaLength = 0
|
self.mediaLength = 0
|
||||||
if self.plugin.mediaController.video( \
|
service_item.title = unicode(self.displayTypeComboBox.currentText())
|
||||||
self.mediaController, filename, False, False):
|
service_item.shortname = service_item.title
|
||||||
self.mediaLength = self.mediaController.media_info.length
|
(path, name) = os.path.split(filename)
|
||||||
service_item.media_length = self.mediaLength
|
service_item.add_from_command(path, name,
|
||||||
self.plugin.mediaController.video_reset(self.mediaController)
|
u':/media/image_clapperboard.png')
|
||||||
if self.mediaLength > 0:
|
# Start media and obtain the length
|
||||||
service_item.add_capability(
|
if not self.plugin.mediaController.media_length(
|
||||||
ItemCapabilities.HasVariableStartTime)
|
self.mediaController, service_item):
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
service_item.media_length = self.mediaLength
|
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
|
||||||
service_item.title = unicode(self.plugin.nameStrings[u'singular'])
|
|
||||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||||
|
|
||||||
|
if Settings().value(self.settingsSection + u'/media auto start',
|
||||||
|
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0]\
|
||||||
|
== QtCore.Qt.Checked:
|
||||||
|
service_item.will_auto_start = True
|
||||||
# force a non-existent theme
|
# force a non-existent theme
|
||||||
service_item.theme = -1
|
service_item.theme = -1
|
||||||
frame = u':/media/image_clapperboard.png'
|
|
||||||
(path, name) = os.path.split(filename)
|
|
||||||
service_item.add_from_command(path, name, frame)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
@ -241,7 +242,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
u' '.join(self.plugin.audio_extensions_list), UiStrings().AllFiles)
|
u' '.join(self.plugin.audio_extensions_list), UiStrings().AllFiles)
|
||||||
|
|
||||||
def displaySetup(self):
|
def displaySetup(self):
|
||||||
self.plugin.mediaController.setup_display( \
|
self.plugin.mediaController.setup_display(
|
||||||
self.mediaController.previewDisplay)
|
self.mediaController.previewDisplay)
|
||||||
|
|
||||||
def populateDisplayTypes(self):
|
def populateDisplayTypes(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user