panda3d/direct/src/interval/SoundInterval.py
2001-03-06 18:20:06 +00:00

47 lines
1011 B
Python

"""SoundInterval module: contains the SoundInterval class"""
from PandaModules import *
from Interval import *
class SoundInterval(Interval):
soundNum = 1
# special methods
def __init__(self, sound, loop=0, name=None):
"""__init__(sound, loop, name)
"""
self.sound = sound
duration = self.sound.length()
self.loop = loop
self.isPlaying = 0
if (name == None):
n = 'Sound-%d' % self.soundNum
self.soundNum = self.soundNum + 1
else:
n = name
self.prevt = 0.0
Interval.__init__(self, n, duration)
def setT(self, t, entry=0):
""" setT(t, entry)
Go to time t
"""
if (t < 0):
self.prevt = t
return
elif (t > self.duration):
if (self.isPlaying == 1):
AudioManager.stop(self.sound)
self.isPlaying = 0
return
elif (entry == 1):
self.isPlaying = 1
if (self.prevt < 0.0):
AudioManager.play(self.sound)
else:
AudioManager.play(self.sound, t)
if (self.loop):
AudioManager.setLoop(self.sound, 1)