ya2 · news · projects · code · about

renamed lib to ya2
[pmachines.git] / ya2 / lib / p3d / audio.py
1 from panda3d.core import AudioSound
2
3
4 class P3dSound:
5
6 def __init__(self, filepath):
7 self.snd = loader.loadSfx(filepath)
8
9 def stop(self): return self.snd.stop()
10 def set_loop(self, val): return self.snd.set_loop(val)
11 def set_volume(self, vol): return self.snd.set_volume(vol)
12 def set_play_rate(self, rate): return self.snd.set_play_rate(rate)
13
14 def play(self):
15 if self.snd.status() != AudioSound.PLAYING: return self.snd.play()
16 return None
17
18 @property
19 def playing(self): return self.snd.status() == AudioSound.PLAYING