mirror of https://gitlab.com/openlp/openlp.git
Video lenght 2
This commit is contained in:
parent
1df6934bda
commit
a3b2fcd113
|
@ -334,6 +334,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||
"""
|
||||
Add a file to the list widget to make it available for showing
|
||||
"""
|
||||
print self.onNewFileMasks
|
||||
files = QtGui.QFileDialog.getOpenFileNames(
|
||||
self, self.onNewPrompt,
|
||||
SettingsManager.get_last_dir(self.settingsSection),
|
||||
|
|
|
@ -71,30 +71,26 @@ class MediaInfo(object):
|
|||
|
||||
def get_media_players():
|
||||
"""
|
||||
This method extract the configured media players and overridden player from
|
||||
the settings.
|
||||
|
||||
``players_list``
|
||||
A list with all active media players.
|
||||
|
||||
``overridden_player``
|
||||
Here an special media player is chosen for all media actions.
|
||||
This method extracts the configured media players and overridden player
|
||||
from the settings.
|
||||
"""
|
||||
log.debug(u'get_media_players')
|
||||
players = unicode(Settings().value(u'media/players').toString())
|
||||
if not players:
|
||||
players = u'webkit'
|
||||
saved_players = unicode(Settings().value(u'media/players').toString())
|
||||
if not saved_players:
|
||||
# we must always have a player and Webkit is the core one.
|
||||
saved_players = u'webkit'
|
||||
reg_ex = QtCore.QRegExp(".*\[(.*)\].*")
|
||||
if Settings().value(u'media/override player',
|
||||
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == QtCore.Qt.Checked:
|
||||
if reg_ex.exactMatch(players):
|
||||
if reg_ex.exactMatch(saved_players):
|
||||
overridden_player = u'%s' % reg_ex.cap(1)
|
||||
else:
|
||||
overridden_player = u'auto'
|
||||
else:
|
||||
overridden_player = u''
|
||||
players_list = players.replace(u'[', u'').replace(u']', u'').split(u',')
|
||||
return players_list, overridden_player
|
||||
saved_players_list = saved_players.replace(u'[', u'').\
|
||||
replace(u']',u'').split(u',')
|
||||
return saved_players_list, overridden_player
|
||||
|
||||
|
||||
def set_media_players(players_list, overridden_player=u'auto'):
|
||||
|
|
|
@ -47,6 +47,8 @@ class MediaController(object):
|
|||
"""
|
||||
|
||||
def __init__(self, parent):
|
||||
print "Media Controller "
|
||||
print parent
|
||||
self.parent = parent
|
||||
self.mediaPlayers = {}
|
||||
self.controller = []
|
||||
|
@ -106,7 +108,7 @@ class MediaController(object):
|
|||
u'core', u'ui', u'media')
|
||||
for filename in os.listdir(controller_dir):
|
||||
if filename.endswith(u'player.py') and not \
|
||||
filename == 'media_player.py':
|
||||
filename == 'mediaplayer.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
modulename = u'openlp.core.ui.media.' + \
|
||||
|
@ -287,11 +289,13 @@ class MediaController(object):
|
|||
"""
|
||||
player.resize(display)
|
||||
|
||||
def video(self, controller, file, muted, isBackground, hidden=False):
|
||||
def video(self, controller, serviceItem, muted, isBackground,
|
||||
hidden=False):
|
||||
"""
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
log.debug(u'video')
|
||||
print "hallo mum"
|
||||
isValid = False
|
||||
# stop running videos
|
||||
self.video_reset(controller)
|
||||
|
@ -300,7 +304,7 @@ class MediaController(object):
|
|||
controller.media_info.volume = 0
|
||||
else:
|
||||
controller.media_info.volume = controller.volumeSlider.value()
|
||||
controller.media_info.file_info = QtCore.QFileInfo(file)
|
||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_filename())
|
||||
controller.media_info.is_background = isBackground
|
||||
display = None
|
||||
if controller.isLive:
|
||||
|
@ -318,7 +322,7 @@ class MediaController(object):
|
|||
else:
|
||||
controller.media_info.start_time = \
|
||||
display.serviceItem.start_time
|
||||
controller.media_info.end_time = display.serviceItem.end_time
|
||||
controller.media_info.end_time = serviceItem.end_time
|
||||
elif controller.previewDisplay:
|
||||
display = controller.previewDisplay
|
||||
isValid = self.check_file_type(controller, display)
|
||||
|
@ -338,8 +342,9 @@ class MediaController(object):
|
|||
# Preview requested
|
||||
if not controller.isLive:
|
||||
autoplay = True
|
||||
# Visible or background requested
|
||||
elif not hidden or controller.media_info.is_background:
|
||||
# Visible or background requested or Service Item wants autostart
|
||||
elif not hidden or controller.media_info.is_background or \
|
||||
serviceItem.will_auto_start:
|
||||
autoplay = True
|
||||
# Unblank on load set
|
||||
elif Settings().value(u'general/auto unblank',
|
||||
|
@ -356,9 +361,15 @@ class MediaController(object):
|
|||
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
||||
return True
|
||||
|
||||
def media_length(self, controller, service_item):
|
||||
def media_length(self, controller, serviceItem):
|
||||
"""
|
||||
Loads and starts a video to run with the option of sound
|
||||
Loads and starts a media item to obtain the media length
|
||||
|
||||
``msg``
|
||||
First element is the controller which should be used
|
||||
|
||||
``serviceItem``
|
||||
The ServiceItem containing the details to be played.
|
||||
"""
|
||||
print controller
|
||||
log.debug(u'media_length')
|
||||
|
@ -366,7 +377,7 @@ class MediaController(object):
|
|||
self.video_reset(controller)
|
||||
controller.media_info = MediaInfo()
|
||||
controller.media_info.volume = controller.volumeSlider.value()
|
||||
controller.media_info.file_info = QtCore.QFileInfo(service_item
|
||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem
|
||||
.get_filename())
|
||||
display = controller.previewDisplay
|
||||
if not self.check_file_type(controller, display):
|
||||
|
@ -376,13 +387,13 @@ class MediaController(object):
|
|||
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
|
||||
serviceItem.set_media_length(controller.media_info.length)
|
||||
self.video_stop([controller])
|
||||
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
|
||||
return True
|
||||
|
|
|
@ -97,8 +97,8 @@ class ServiceManager(QtGui.QWidget):
|
|||
"""
|
||||
Manages the services. This involves taking text strings from plugins and
|
||||
adding them to the service. This service can then be zipped up with all
|
||||
the resources used into one OSZ file for use on any OpenLP v2 installation.
|
||||
Also handles the UI tasks of moving things up and down etc.
|
||||
the resources used into one OSZ or oszl file for use on any OpenLP v2
|
||||
installation. Also handles the UI tasks of moving things up and down etc.
|
||||
"""
|
||||
def __init__(self, mainwindow, parent=None):
|
||||
"""
|
||||
|
@ -425,7 +425,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
SettingsManager.get_last_dir(
|
||||
self.mainwindow.serviceManagerSettingsSection),
|
||||
translate('OpenLP.ServiceManager',
|
||||
'OpenLP Service Files (*.osz)')))
|
||||
'OpenLP Service Files (*.osz *.ozl)')))
|
||||
if not fileName:
|
||||
return False
|
||||
else:
|
||||
|
@ -594,6 +594,75 @@ class ServiceManager(QtGui.QWidget):
|
|||
delete_file(temp_file_name)
|
||||
return success
|
||||
|
||||
def saveLocalFile(self):
|
||||
"""
|
||||
Save the current service file.
|
||||
|
||||
A temporary file is created so that we don't overwrite the existing one
|
||||
and leave a mangled service file should there be an error when saving.
|
||||
Audio files are also copied into the service manager directory, and
|
||||
then packaged into the zip file.
|
||||
"""
|
||||
if not self.fileName():
|
||||
return self.saveFileAs()
|
||||
temp_file, temp_file_name = mkstemp(u'.oszl', u'openlp_')
|
||||
# We don't need the file handle.
|
||||
os.close(temp_file)
|
||||
log.debug(temp_file_name)
|
||||
path_file_name = unicode(self.fileName())
|
||||
path, file_name = os.path.split(path_file_name)
|
||||
basename = os.path.splitext(file_name)[0]
|
||||
service_file_name = '%s.osd' % basename
|
||||
log.debug(u'ServiceManager.saveFile - %s', path_file_name)
|
||||
SettingsManager.set_last_dir(
|
||||
self.mainwindow.serviceManagerSettingsSection,
|
||||
path)
|
||||
service = []
|
||||
total_size = 0
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
# Number of items + 1 to zip it
|
||||
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
||||
for item in self.serviceItems:
|
||||
self.mainwindow.incrementProgressBar()
|
||||
service_item = item[u'service_item'].get_service_repr()
|
||||
service.append({u'serviceitem': service_item})
|
||||
service_content = cPickle.dumps(service)
|
||||
# Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be
|
||||
# extracted using unzip in UNIX.
|
||||
allow_zip_64 = (total_size > 2147483648 + len(service_content))
|
||||
log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64)
|
||||
zip = None
|
||||
success = True
|
||||
self.mainwindow.incrementProgressBar()
|
||||
try:
|
||||
zip = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED,
|
||||
allow_zip_64)
|
||||
# First we add service contents.
|
||||
zip.writestr(service_file_name.encode(u'utf-8'), service_content)
|
||||
except IOError:
|
||||
log.exception(u'Failed to save service to disk: %s', temp_file_name)
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate(u'OpenLP.ServiceManager',
|
||||
u'Error Saving File'),
|
||||
u'message': translate(u'OpenLP.ServiceManager',
|
||||
u'There was an error saving your file.')
|
||||
})
|
||||
success = False
|
||||
finally:
|
||||
if zip:
|
||||
zip.close()
|
||||
self.mainwindow.finishedProgressBar()
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
if success:
|
||||
try:
|
||||
shutil.copy(temp_file_name, path_file_name)
|
||||
except:
|
||||
return self.saveFileAs()
|
||||
self.mainwindow.addRecentFile(path_file_name)
|
||||
self.setModified(False)
|
||||
delete_file(temp_file_name)
|
||||
return success
|
||||
|
||||
def saveFileAs(self):
|
||||
"""
|
||||
Get a file name and then call :func:`ServiceManager.saveFile` to
|
||||
|
@ -632,7 +701,9 @@ class ServiceManager(QtGui.QWidget):
|
|||
path = os.path.join(directory, default_filename)
|
||||
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow,
|
||||
UiStrings().SaveService, path,
|
||||
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')))
|
||||
translate('OpenLP.ServiceManager',
|
||||
'OpenLP Service Files (*.osz);;'
|
||||
'OpenLP Service Files - light (*.oszl)')))
|
||||
if not fileName:
|
||||
return False
|
||||
if os.path.splitext(fileName)[1] == u'':
|
||||
|
@ -641,6 +712,9 @@ class ServiceManager(QtGui.QWidget):
|
|||
ext = os.path.splitext(fileName)[1]
|
||||
fileName.replace(ext, u'.osz')
|
||||
self.setFileName(fileName)
|
||||
if suffix == u'.oszl':
|
||||
return self.saveLocalFile()
|
||||
else:
|
||||
return self.saveFile()
|
||||
|
||||
def loadFile(self, fileName):
|
||||
|
@ -774,10 +848,10 @@ class ServiceManager(QtGui.QWidget):
|
|||
.is_capable(ItemCapabilities.CanAutoStartForLive):
|
||||
self.autoStartAction.setVisible(True)
|
||||
self.autoStartAction.setText(translate('OpenLP.ServiceManager',
|
||||
'&Auto Start - Disabled'))
|
||||
'&Auto Start - inactive'))
|
||||
if serviceItem[u'service_item'].will_auto_start:
|
||||
self.autoStartAction.setText(translate('OpenLP.ServiceManager',
|
||||
'&Auto Start - Enabled'))
|
||||
'&Auto Start - active'))
|
||||
self.themeMenu.menuAction().setVisible(False)
|
||||
# Set up the theme menu.
|
||||
if serviceItem[u'service_item'].is_text() and \
|
||||
|
@ -819,6 +893,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
item = self.findServiceItem()[0]
|
||||
self.serviceItems[item][u'service_item'].will_auto_start = \
|
||||
not self.serviceItems[item][u'service_item'].will_auto_start
|
||||
a=1
|
||||
|
||||
|
||||
def onServiceItemEditForm(self):
|
||||
|
@ -1395,6 +1470,9 @@ class ServiceManager(QtGui.QWidget):
|
|||
filename = unicode(url.toLocalFile())
|
||||
if filename.endswith(u'.osz'):
|
||||
self.onLoadServiceClicked(filename)
|
||||
elif filename.endswith(u'.oszl'):
|
||||
# todo correct
|
||||
self.onLoadServiceClicked(filename)
|
||||
elif link.hasText():
|
||||
plugin = unicode(link.text())
|
||||
item = self.serviceManagerList.itemAt(event.pos())
|
||||
|
|
|
@ -54,13 +54,15 @@ class SlideList(QtGui.QTableWidget):
|
|||
|
||||
class Controller(QtGui.QWidget):
|
||||
"""
|
||||
Controller is a general controller widget.
|
||||
Controller is a general display controller widget.
|
||||
"""
|
||||
def __init__(self, parent, isLive=False):
|
||||
"""
|
||||
Set up the general Controller.
|
||||
"""
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
print "Controller"
|
||||
print parent
|
||||
self.isLive = isLive
|
||||
self.display = None
|
||||
|
||||
|
@ -1346,8 +1348,7 @@ class SlideController(Controller):
|
|||
Respond to the arrival of a media service item
|
||||
"""
|
||||
log.debug(u'SlideController onMediaStart')
|
||||
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
||||
self.mediaController.video(self, file, False, False, self.hideMode())
|
||||
self.mediaController.video(self, item, False, False, self.hideMode())
|
||||
if not self.isLive or self.mediaController.withLivePreview:
|
||||
self.previewDisplay.show()
|
||||
self.slidePreview.hide()
|
||||
|
|
|
@ -169,6 +169,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||
"""
|
||||
Called to replace Live background with the media selected.
|
||||
"""
|
||||
# Todo fix me up
|
||||
if check_item_selected(self.listView,
|
||||
translate('MediaPlugin.MediaItem',
|
||||
'You must select a media file to replace the background with.')):
|
||||
|
@ -203,7 +204,6 @@ class MediaMediaItem(MediaManagerItem):
|
|||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'The file %s no longer exists.')) % filename)
|
||||
return False
|
||||
self.mediaLength = 0
|
||||
service_item.title = unicode(self.displayTypeComboBox.currentText())
|
||||
service_item.shortname = service_item.title
|
||||
(path, name) = os.path.split(filename)
|
||||
|
@ -215,7 +215,6 @@ class MediaMediaItem(MediaManagerItem):
|
|||
return False
|
||||
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
|
||||
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:
|
||||
|
|
|
@ -17,6 +17,11 @@ Notes:
|
|||
<sub-class-of type="application/zip"/>
|
||||
<comment>OpenLP Service File</comment>
|
||||
<glob pattern="*.osz"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-openlp-service">
|
||||
<sub-class-of type="application/zip"/>
|
||||
<comment>OpenLP Service File</comment>
|
||||
<glob pattern="*.oszl"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-openlp-theme">
|
||||
<sub-class-of type="application/zip"/>
|
||||
|
|
Loading…
Reference in New Issue