FMOD-EX and setFinishedEvent

I have a code snippet:

        if self.finishEventName != None:            

…which is fine when using OpenAL. But I am trying to use FMOD. With FMOD, I get:

:audio(error): set_finished_event: not implemented under FMOD-EX

Is there a workaround?

Many thanks,

You can start a doMethodLater() based on the duration of the sound.


Worked like a charm! :slight_smile: As always - thanks David!

I hit a snag with the doMethodLater approach. In the scenario where “stop” is called on a sound - finished event does not fire. With the do later approach - it always fires.

I ended up just adding a task:

    def stop(self):
        self.watchForFinish = False

    def monitor(self,t):
        if (self.sound.status() != self.sound.PLAYING) and self.watchForFinish == True:
            # print "trigger end"
            taskMgr.add(messenger.send, self.finishEventName, extraArgs = [self.finishEventName], priority=1)
            self.watchForFinish = False
        return Task.cont


Store the task (the result of taskMgr.add) in a variable and remove the task when you stop the sound.

Is that necessary? The method being used does not return Task.cont - so the task will only run once right? And I assume as such removes itself?


Sorry, I think I misunderstood your problem.

Is the problem that when you call stop() on the sound, the event still fires later?

Ah, no.

Problem was, using OpenAL, I could use setFinishedEvent. Now, when I did that, it worked well because the event would only actually fire if the sound finished playing and did not fire when stop was called. That is the behaviour I wanted but was forced to move to FMOD. FMOD does not support “setFinishedEvent” so I simply added a task to monitor the sound and fire an event on finish.