Announcement

Collapse
No announcement yet.

Is there a callback when a sound cue has finished playing?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is there a callback when a sound cue has finished playing?

    Hi there,

    I want to get a callback of some kind when my sound has finished playing. Is there a way I can do that?
    I have a sound cue containing a part of dialogue. I want to know when it is finished so I can play the next part of the conversation.

    Thanks,
    - Rich

    #2
    I was looking into that issue as I had that problem with UMG animations. I solved it with the use of delay nodes and some other workarounds, but I don't exactly like it either .
    Song of Horror's official website
    Song of Horror Facebook , Twitter and YouTube
    Check us out on our Forum thread too!

    Comment


      #3
      I see. Thanks for the reply. Yes, I could use a delay node.
      The issue for me is, I don't know how long the dialogue is going to be. Is there a way to find out the duration of a sound?

      Comment


        #4
        UAudioComponent has an OnAudioFinished delegate that you can hook an event to.

        Comment


          #5
          Originally posted by RodeoRich View Post
          UAudioComponent has an OnAudioFinished delegate that you can hook an event to.
          This is the way to do it - the trouble is that it isn't easy to use from within Blueprint. I used a custom component to manage audio components, bind the delegate and trigger a blueprint event within that class (I'd share the code, but it's very specific to the project I'm working on, so not really that useful to anyone else).

          Handling it through audio components isn't a bad way of doing it though. I'd avoid the 'PlaySound' nodes that are available by default if you're going to want a callback when the audio is complete.

          Comment


            #6
            Originally posted by ambershee View Post
            This is the way to do it - the trouble is that it isn't easy to use from within Blueprint. I used a custom component to manage audio components, bind the delegate and trigger a blueprint event within that class (I'd share the code, but it's very specific to the project I'm working on, so not really that useful to anyone else).

            Handling it through audio components isn't a bad way of doing it though. I'd avoid the 'PlaySound' nodes that are available by default if you're going to want a callback when the audio is complete.
            Why is this not easy to use? Why have the bp wich plays the sound in the same bp you can handle the OnEndPlay (or whatever you want to call it)
            Click image for larger version

Name:	Unbenannt-2.png
Views:	1
Size:	107.8 KB
ID:	1061507

            Thahts one way to deal asynchronous stuff
            Free Inventory System (BP AND C++ Version): Clicky Clicky
            Player Structure System (Houses!) (BP): Pew Pew Marketplace Version: Yoink!
            Howto: Create Dragable UMG Windows: Zoom Zoom

            Comment


              #7
              I did say handling it through audio components isn't a bad way of doing it. The issue occurs when you're doing it from somewhere like the Level Blueprint, where you're normally expected to use the static gameplay functions rather than components. Whilst you can add an audio component to the level blueprint, or spawn them as and when you need, it's not ideal - hence why I created a class to manage that for me (because this project contains a lot of level specific dialogue).

              Comment


                #8
                Originally posted by ambershee View Post
                I did say handling it through audio components isn't a bad way of doing it. The issue occurs when you're doing it from somewhere like the Level Blueprint, where you're normally expected to use the static gameplay functions rather than components. Whilst you can add an audio component to the level blueprint, or spawn them as and when you need, it's not ideal - hence why I created a class to manage that for me (because this project contains a lot of level specific dialogue).
                ah i see well yes in that case a maybe playback actor would make sense. you would still be able to rerebind the finished event to your maybe level blueprint or whatever
                Free Inventory System (BP AND C++ Version): Clicky Clicky
                Player Structure System (Houses!) (BP): Pew Pew Marketplace Version: Yoink!
                Howto: Create Dragable UMG Windows: Zoom Zoom

                Comment

                Working...
                X