OnEventStopped not called when UFMODAudioComponent is destroyed while playing

I don’t know if this is intentional or not, but i think OnEventStopped should be called when you destroy an UFMODAudioComponent while it’s playing an event.

It does appear to be missing from that case, although wouldn’t it be better to only broadcast OnEventStopped if bStopWhenOwnerDestroyed is true?

Otherwise, if you wanted the event to continue/finish playing after the object is destroyed, you will get the OnEventStopped callback even though it hasn’t stopped.

Yes, that works. Sorry i didn’t see that variable.
Everything should work as it should then :slight_smile:

But then again bStopWhenOwnerDestroyed is true as default but still i don’t get the OnEventStopped broadcast when i destroy the owner.
My solution for this was to do a derived class that broadcasts OnEventStopped on EndPlay().

Apologies for the delay, that does sound like something we could fairly easily add.

Nice! :slight_smile:
Yeah i can see why i dont get the broadcast. The component runs Stop() when parent is destroyed and bStopWhenOwnerDestroyed == true. But the OnEventStopped broadcast is only called in Tick() with OnPlaybackCompleted() and can’t be called since bIsActive is set to false by the Stop() function.

And another thing if it’s not too much , is it possible for you to add virtual to some functions as Play(), Stop() and SetEvent() so we can override and add conditions in derived classes?

We will look into the possibility of adding virtual functions to the FMODAudioComponent for a future release.

1 Like

I did an obsevation that if you stop the event with Stop() it doesn’t broadcast either.
But atm you can’t just add a broadcast in Stop() because that function is also run at the start of Play_Internal() and PostEditChangeProperty().
So things need to be rearranged a bit to make it work.

Stop() itself doesn’t broadcast the delegate, as long as the component is still around the TickComponent will call OnPlaybackCompleted once the event is stopped and trigger the broadcast.

At least this is what should happen, and is what I am seeing happen here.
Are you experiencing something different?

Sorry if i was unclear. I looked through the code and saw that it wasn’t as simple as adding another broadcast to make things work and I just wanted to tell you that.

If you run Stop(), bIsActive is set to false which stops anything to run in TickComponent and therefore no Broadcast. So stuff needs to be changed to make it work.

bIsActive is only set to false in OnPlayBackCompleted, and OnEventStopped is broadcast 3 lines after that.