Browse Source

fix setPlayRate() on running MetaInterval

David Rose 15 years ago
parent
commit
be3a0f3520
1 changed files with 13 additions and 0 deletions
  1. 13 0
      direct/src/interval/MetaInterval.py

+ 13 - 0
direct/src/interval/MetaInterval.py

@@ -460,6 +460,19 @@ class MetaInterval(CMetaInterval):
         else:
         else:
             self.notify.error("Cannot build list from MetaInterval directly.")
             self.notify.error("Cannot build list from MetaInterval directly.")
 
 
+    def setPlayRate(self, playRate):
+        """ Changes the play rate of the interval.  If the interval is
+        already started, this changes its speed on-the-fly.  Note that
+        since playRate is a parameter to start() and loop(), the next
+        call to start() or loop() will reset this parameter. """
+        
+        if self.isPlaying():
+            self.pause()
+            CMetaInterval.setPlayRate(self, playRate)
+            self.resume()
+        else:
+            CMetaInterval.setPlayRate(self, playRate)
+
     def __doPythonCallbacks(self):
     def __doPythonCallbacks(self):
         # This function invokes any Python-level Intervals that need
         # This function invokes any Python-level Intervals that need
         # to be invoked at this point in time.  It must be called
         # to be invoked at this point in time.  It must be called