Hi,
I would like to explicitly finish a SoundInterval which is part of a Sequence. But the result is not as expected.
The audio file encapsulated by the SoundInterval is stopped properly but not the SoundInterval itself.
This is the (test) code:
import os
resourceDir = os.path.dirname(os.path.abspath(__file__)) + <INSERT RES DIR HERE>
from pandac.PandaModules import loadPrcFileData
loadPrcFileData('', 'audio-library-name p3openal_audio')
loadPrcFileData('', 'model-path ' + resourceDir)
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.interval.MetaInterval import Sequence
from direct.interval.FunctionInterval import Func
from direct.interval.SoundInterval import SoundInterval
def doPrint(arg):
print arg
class Test(DirectObject):
def __init__(self):
DirectObject.__init__(self)
self.seq = Sequence(Func(doPrint, 'start'),
SoundInterval(loader.loadSfx(<INSERT ANY AUDIO HERE>)),
Func(doPrint, 'end')
)
self.running = False
self.accept('space', self.onSpace)
def onSpace(self):
if not self.running:
self.seq.start()
self.running = True
else:
for ival in self.seq:
if isinstance(ival, SoundInterval):
ival.finish()
t = Test()
run()
In fact, ‘end’ will not be printed until the SoundInterval is finished, no matter if I press ‘space’ (and audio playback stops) or not.
Any ideas? Are we doing something wrong?
Yours,
rahdev