← Back to team overview

openlp-core team mailing list archive

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

 

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

Requested reviews:
  Jonathan Corwin (j-corwin)

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

Add a timer so the media startup does not go into an infinite spin.  
5 Seconds is long enough!
-- 
https://code.launchpad.net/~trb143/openlp/general/+merge/54051
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2011-03-15 19:55:49 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2011-03-18 18:23:24 +0000
@@ -24,6 +24,7 @@
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 ###############################################################################
 
+from datetime import datetime
 import logging
 import os
 
@@ -139,11 +140,16 @@
             file_size = os.path.getsize(filename)
             # File too big for processing
             if file_size <= 52428800: # 50MiB
+                start = datetime.now()
                 while not self.mediaState:
                     Receiver.send_message(u'openlp_process_events')
-                service_item.media_length = self.mediaLength
-                service_item.add_capability(
-                    ItemCapabilities.AllowsVariableStartTime)
+                    tme = datetime.now() - start
+                    if tme.seconds > 5:
+                       break
+                if self.mediaState:
+                    service_item.media_length = self.mediaLength
+                    service_item.add_capability(
+                        ItemCapabilities.AllowsVariableStartTime)
             service_item.add_from_command(path, name, frame)
             return True
         else:
@@ -189,4 +195,4 @@
         if newState == Phonon.PlayingState:
             self.mediaState = newState
             self.mediaLength = self.mediaObject.totalTime()/1000
-            self.mediaObject.stop()
\ No newline at end of file
+            self.mediaObject.stop()