# OnEventStopped not called when UFMODAudioComponent is destroyed while playing

**URL:** <https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585>\
**Category:** Unreal Engine\
**Created:** [April 18, 2019, 2:58pm UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585 "2019-04-18T14:58:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cark](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@cark](https://qa.fmod.com/u/cark)\
**Post date:** [April 18, 2019, 2:58pm UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/1 "2019-04-18T14:58:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [April 24, 2019, 3:24am UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/2 "2019-04-24T03:24:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cark](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@cark](https://qa.fmod.com/u/cark)\
**Post date:** [April 24, 2019, 7:49am UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/3 "2019-04-24T07:49:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cark](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@cark](https://qa.fmod.com/u/cark)\
**Post date:** [April 24, 2019, 8:01am UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/4 "2019-04-24T08:01:22Z")

</div>

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().

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 1, 2019, 5:29am UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/5 "2019-05-01T05:29:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cark](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@cark](https://qa.fmod.com/u/cark)\
**Post date:** [May 7, 2019, 12:29pm UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/6 "2019-05-07T12:29:19Z")

</div>

Nice! 🙂  
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?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 9, 2019, 3:44am UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/7 "2019-05-09T03:44:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cark](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@cark](https://qa.fmod.com/u/cark)\
**Post date:** [May 24, 2019, 3:35pm UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/8 "2019-05-24T15:35:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 27, 2019, 1:20am UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/9 "2019-05-27T01:20:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cark](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@cark](https://qa.fmod.com/u/cark)\
**Post date:** [May 27, 2019, 12:20pm UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/10 "2019-05-27T12:20:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 27, 2019, 11:02pm UTC](https://qa.fmod.com/t/oneventstopped-not-called-when-ufmodaudiocomponent-is-destroyed-while-playing/14585/11 "2019-05-27T23:02:32Z")

</div>

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