Video length tagging and display

This commit is contained in:
Tim Bentley 2011-02-13 10:37:27 +00:00
parent d98ea53cc1
commit 57c0ab31dc
4 changed files with 39 additions and 2 deletions

View File

@ -28,11 +28,14 @@ The :mod:`serviceitem` provides the service item functionality including the
type and capability of an item.
"""
import datetime
import logging
import mutagen
import os
import uuid
from openlp.core.lib import build_icon, clean_tags, expand_tags
from openlp.core.lib.ui import UiStrings
log = logging.getLogger(__name__)
@ -106,7 +109,7 @@ class ServiceItem(object):
self.data_string = u''
self.edit_id = None
self.xml_version = None
self.start_time =[0, 0, 0]
self.start_time = [0, 0, 0]
self._new_item()
def _new_item(self):
@ -425,3 +428,30 @@ class ServiceItem(object):
return self._raw_frames[row][u'path']
except IndexError:
return u''
def get_media_time(self):
"""
Returns the start and finish time for a media item
"""
tooltip = None
start = None
end = None
if self.start_time != [0, 0, 0]:
start = UiStrings.Start % \
(self.start_time[0], self.start_time[1], self.start_time[2])
path = os.path.join(self.get_frames()[0][u'path'],
self.get_frames()[0][u'title'])
if os.path.isfile(path):
file = mutagen.File(path)
if file is not None:
seconds = int(file.info.length)
end = UiStrings.Length % \
unicode(datetime.timedelta(seconds=seconds))
if not start and not end:
return None
elif start and not end:
return start
elif not start and end:
return end
else:
return u'%s : %s' % (start, end)

View File

@ -58,6 +58,7 @@ class UiStrings(object):
ExportType = unicode(translate('OpenLP.Ui', 'Export %s'))
Import = translate('OpenLP.Ui', 'Import')
ImportType = unicode(translate('OpenLP.Ui', 'Import %s'))
Length = unicode(translate('OpenLP.Ui', 'Length %s'))
Live = translate('OpenLP.Ui', 'Live')
Load = translate('OpenLP.Ui', 'Load')
LoadANew = unicode(translate('OpenLP.Ui', 'Load a new %s.'))
@ -75,10 +76,10 @@ class UiStrings(object):
SendSelectLive = unicode(translate('OpenLP.Ui',
'Send the selected %s live.'))
Service = translate('OpenLP.Ui', 'Service')
Start = unicode(translate('OpenLP.Ui', 'Start %02d:%02d:%02d'))
Theme = translate('OpenLP.Ui', 'Theme')
Themes = translate('OpenLP.Ui', 'Themes')
def add_welcome_page(parent, image):
"""
Generate an opening welcome page for a wizard using a provided image.

View File

@ -611,12 +611,14 @@ class ServiceManager(QtGui.QWidget):
item = self.findServiceItem()[0]
self.startTimeForm.item = self.serviceItems[item]
if self.startTimeForm.exec_():
self.serviceItems[item][u'service_item'].start_time = [0, 0, 0]
self.serviceItems[item][u'service_item'].start_time[0] = \
self.startTimeForm.hourSpinBox.value()
self.serviceItems[item][u'service_item'].start_time[1] = \
self.startTimeForm.minuteSpinBox.value()
self.serviceItems[item][u'service_item'].start_time[2] = \
self.startTimeForm.secondSpinBox.value()
self.repaintServiceList(item, -1)
def onServiceItemEditForm(self):
item = self.findServiceItem()[0]
@ -864,6 +866,9 @@ class ServiceManager(QtGui.QWidget):
text = frame[u'title'].replace(u'\n', u' ')
child.setText(0, text[:40])
child.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(count))
tip= item[u'service_item'].get_media_time()
if tip:
child.setToolTip(0, tip)
if serviceItem == itemcount:
if item[u'expanded'] and serviceItemChild == count:
self.serviceManagerList.setCurrentItem(child)

View File

@ -46,3 +46,4 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
self.minuteSpinBox.setValue(self.item[u'service_item'].start_time[1])
self.secondSpinBox.setValue(self.item[u'service_item'].start_time[2])
return QtGui.QDialog.exec_(self)