← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bugs into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bugs into lp:openlp.

Requested reviews:
  Jon Tibble (meths)
Related bugs:
  #693150 Custom Slide Display footer option
  https://bugs.launchpad.net/bugs/693150
  #693202 delete theme
  https://bugs.launchpad.net/bugs/693202

For more details, see:
https://code.launchpad.net/~trb143/openlp/bugs/+merge/49687

fix video length calculation cos it was very wrong.
Remove the need for the mutagen as not needed.


-- 
https://code.launchpad.net/~trb143/openlp/bugs/+merge/49687
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2011-02-13 13:11:15 +0000
+++ openlp/core/lib/serviceitem.py	2011-02-14 18:46:15 +0000
@@ -30,7 +30,6 @@
 
 import datetime
 import logging
-import mutagen
 import os
 import uuid
 
@@ -110,6 +109,7 @@
         self.edit_id = None
         self.xml_version = None
         self.start_time = 0
+        self.media_length = 0
         self._new_item()
 
     def _new_item(self):
@@ -263,7 +263,8 @@
             u'search': self.search_string,
             u'data': self.data_string,
             u'xml_version': self.xml_version,
-            u'start_time': self.start_time
+            u'start_time': self.start_time,
+            u'media_length': self.media_length
         }
         service_data = []
         if self.service_item_type == ServiceItemType.Text:
@@ -309,6 +310,8 @@
             self.xml_version = header[u'xml_version']
         if u'start_time' in header:
             self.start_time = header[u'start_time']
+        if u'media_length' in header:
+            self.media_length = header[u'media_length']
         if self.service_item_type == ServiceItemType.Text:
             for slide in serviceitem[u'serviceitem'][u'data']:
                 self._raw_frames.append(slide)
@@ -439,14 +442,9 @@
         if self.start_time != 0:
             start = UiStrings.StartTimeCode % \
                 unicode(datetime.timedelta(seconds=self.start_time))
-        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.LengthTime % \
-                    unicode(datetime.timedelta(seconds=seconds))
+        if self.media_length != 0:
+            end = UiStrings.LengthTime % \
+                unicode(datetime.timedelta(seconds=self.media_length))
         if not start and not end:
             return None
         elif start and not end:

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2011-02-13 13:11:15 +0000
+++ openlp/core/ui/maindisplay.py	2011-02-14 18:46:15 +0000
@@ -348,7 +348,7 @@
         """
         Start the video at a predetermined point.
         """
-        if newState == 2:
+        if newState == Phonon.PlayingState:
             self.mediaObject.seek(self.serviceItem.start_time * 1000)
 
     def isWebLoaded(self):

=== modified file 'openlp/core/ui/printserviceorderform.py'
--- openlp/core/ui/printserviceorderform.py	2011-02-07 17:27:38 +0000
+++ openlp/core/ui/printserviceorderform.py	2011-02-14 18:46:15 +0000
@@ -24,7 +24,6 @@
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
 import datetime
-import mutagen
 import os
 
 from PyQt4 import QtCore, QtGui
@@ -113,16 +112,9 @@
                         item.notes.replace(u'\n', u'<br />'))
             # Add play length of media files.
             if item.is_media() and self.printMetaDataCheckBox.isChecked():
-                path = os.path.join(item.get_frames()[0][u'path'],
-                    item.get_frames()[0][u'title'])
-                if not os.path.isfile(path):
-                    continue
-                file = mutagen.File(path)
-                if file is not None:
-                    length = int(file.info.length)
-                    text += u'<p><b>%s</b> %s</p>' % (translate(
-                        'OpenLP.ServiceManager', u'Playing time:'),
-                        unicode(datetime.timedelta(seconds=length)))
+                text += u'<p><b>%s</b> %s</p>' % (translate(
+                    'OpenLP.ServiceManager', u'Playing time:'),
+                    unicode(datetime.timedelta(seconds=item.media_length)))
         if self.customNoteEdit.toPlainText():
             text += u'<h4>%s</h4>%s' % (translate('OpenLP.ServiceManager',
                 u'Custom Service Notes:'), self.customNoteEdit.toPlainText())

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2011-02-12 10:04:10 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2011-02-14 18:46:15 +0000
@@ -32,6 +32,7 @@
 from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
     SettingsManager, translate, check_item_selected, Receiver
 from openlp.core.lib.ui import UiStrings, critical_error_message_box
+from PyQt4.phonon import Phonon
 
 log = logging.getLogger(__name__)
 
@@ -48,9 +49,13 @@
             u':/media/media_video.png').toImage()
         MediaManagerItem.__init__(self, parent, self, icon)
         self.singleServiceItem = False
+        self.mediaObject = Phonon.MediaObject(self)
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'video_background_replaced'),
             self.videobackgroundReplaced)
+        QtCore.QObject.connect(self.mediaObject,
+            QtCore.SIGNAL(u'stateChanged(Phonon::State, Phonon::State)'),
+            self.videoStart)
 
     def retranslateUi(self):
         self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
@@ -120,6 +125,11 @@
                 return False
         filename = unicode(item.data(QtCore.Qt.UserRole).toString())
         if os.path.exists(filename):
+            self.MediaState = None
+            self.mediaObject.stop()
+            self.mediaObject.clearQueue()
+            self.mediaObject.setCurrentSource(Phonon.MediaSource(filename))
+            self.mediaObject.play()
             service_item.title = unicode(
                 translate('MediaPlugin.MediaItem', 'Media'))
             service_item.add_capability(ItemCapabilities.RequiresMedia)
@@ -128,6 +138,9 @@
             service_item.theme = -1
             frame = u':/media/image_clapperboard.png'
             (path, name) = os.path.split(filename)
+            while not self.MediaState:
+                Receiver.send_message(u'openlp_process_events')
+            service_item.media_length = self.mediaLength
             service_item.add_from_command(path, name, frame)
             return True
         else:
@@ -165,3 +178,12 @@
             item_name.setIcon(build_icon(img))
             item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
             self.listView.addItem(item_name)
+
+    def videoStart(self, newState, oldState):
+        """
+        Start the video at a predetermined point.
+        """
+        if newState == Phonon.PlayingState:
+            self.MediaState = newState
+            self.mediaLength = self.mediaObject.totalTime()/1000
+            self.mediaObject.stop()


Follow ups