diff --git a/direct/src/interval/SoundInterval.py b/direct/src/interval/SoundInterval.py index 24d03cfaab..6d623e65bc 100644 --- a/direct/src/interval/SoundInterval.py +++ b/direct/src/interval/SoundInterval.py @@ -54,7 +54,8 @@ class SoundInterval(Interval): # Update sound based on current time if (t >= self.getDuration()): # If end of sound reached or stop event received, stop sound - self.sound.stop() + if self.sound: + self.sound.stop() self.ignore(self.stopEvent) elif (event == IVAL_INIT): # IVAL_INIT event, start new sound @@ -62,13 +63,14 @@ class SoundInterval(Interval): # start at the beginning if (t < 0.1): t = 0.0 - # Start sound - self.sound.setTime(t) - self.sound.setLoop(self.loop) - self.sound.setVolume(self.volume) - self.sound.play() - # Accept event to kill sound - self.acceptOnce(self.stopEvent, + if self.sound: + # Start sound + self.sound.setTime(t) + self.sound.setLoop(self.loop) + self.sound.setVolume(self.volume) + self.sound.play() + # Accept event to kill sound + self.acceptOnce(self.stopEvent, lambda s = self: s.sound.stop()) # Print debug information self.notify.debug('updateFunc() - %s: t = %f' % (self.name, t)) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 5ca14a5203..095059912a 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -343,14 +343,6 @@ class ShowBase: self.notify.warning("Could not load music file %s." % name) return sound - def unloadSfx(self, sfx): - if sfx: - del sfx - - def unloadMusic(self, music): - if music: - del music - def playSfx(self, sfx, looping = 0, interupt = 1, volume = None, time = 0.): if sfx: @@ -371,14 +363,6 @@ class ShowBase: music.setLoop(looping) music.play() - def stopSfx(self, sfx): - if sfx: - sfx.stop() - - def stopMusic(self, music): - if music: - music.stop() - def dataloop(self, state): # traverse the data graph. This reads all the control # inputs (from the mouse and keyboard, for instance) and also