Browse Source

*** empty log message ***

Mike Goslin 25 years ago
parent
commit
19158dfd98

+ 0 - 2
direct/src/interval/IntervalTest.py

@@ -5,8 +5,6 @@ from IntervalGlobal import *
 import Mopath
 import IntervalPlayer
 
-#AudioManager.spawnUpdate()
-
 boat = loader.loadModel('models/directmodels/smiley')
 boat.reparentTo(render)
 

+ 29 - 0
direct/src/interval/MultiTrack.py

@@ -2,6 +2,8 @@
 
 import Interval
 import Track
+import ClockObject
+import Task
 
 class MultiTrack(Interval.Interval):
 
@@ -21,6 +23,7 @@ class MultiTrack(Interval.Interval):
 	self.duration = self.getDuration()
 	self.startTime = 0.0
 	self.type = Interval.PREVIOUS_END
+	self.clock = ClockObject.ClockObject.getGlobalClock()
 
     def getDuration(self):
 	""" getDuration()
@@ -42,3 +45,29 @@ class MultiTrack(Interval.Interval):
 		'MultiTrack.setT(): t = %f > duration' % t)
 	for track in self.tlist:
 	    track.setT(t)
+
+    def play(self, t0=0.0, duration=0.0):
+	""" play(t0, duration)
+	"""
+	self.startT = self.clock.getFrameTime() - t0
+	if (duration == 0.0):
+	    self.playDuration = self.duration
+	else:
+	    self.playDuration = duration
+	taskMgr.spawnMethodNamed(self.__playTask, self.name + '-play')
+
+    def stop(self):
+	""" stop()
+	"""
+	taskMgr.removeMethodsNamed(self.name + '-play')
+
+    def __playTask(self, task):
+	""" __playTask(task)
+	"""
+	t = self.clock.getFrameTime()
+	te = t - self.startT
+	if (te <= self.playDuration):
+	    self.setT(te)
+	    return Task.cont
+	else:
+	    return Task.done

+ 1 - 0
direct/src/interval/SoundInterval.py

@@ -32,6 +32,7 @@ class SoundInterval(Interval.Interval):
 	if (t > self.duration):
 	    if (self.isPlaying == 1):
 		AudioManager.stop(self.sound)
+		self.isPlaying = 0
 	    return
 	assert(t >= 0)
 	if (t == 0):