Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to pause a wav Sound / Sound Cue ?

I'm trying to pause a sound and then resume it after a certain time (changes dynamically). How could I do this in Blueprints? I know I can play from a time and stop it, but I want to pause and resume.

Product Version: Not Selected
more ▼

asked Jun 26 '14 at 09:26 AM in Blueprint Scripting

avatar image

83 5 8 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I know this is an old post, but I'm posting my method in case someone stumbles across this question. I did a very simple blueprint logic (and probably inefficient, but works for me.) I track the time the sound plays by a variable, let's assume MusicPlayedFor. This is initially set to 0 at the beginning.

Whenever my sound starts playing, I set the time by Get Audio Time Seconds into a variable, let's say MusicStartedAt.

Whenever it 'pauses' (in my case, by player input), it actually Stops and set another variable MusicPausedAt by the Get Audio Time Seconds. alt text Subtracting: MusicPausedAt - MusicStartedAt gives the time the current chunk of sound played.

Adding: MusicStartedAt = MusicStartedAt + ( MusicPausedAt - MusicStartedAt) gives the time from the start of the sound till the pause action.

Then, when the next time Play is hit, simply pipe this time into the Start Time pin of the Play node. Sound will start playing from where it left off. alt text

All this higgedly-piggely will be unnecessary once the devs simply expose a stupid pause node. Till then, I'm sticking to this solution. Comments and criticisms are welcome!

picture1.png (273.9 kB)
picture2.png (429.0 kB)
more ▼

answered Dec 04 '16 at 06:05 AM

avatar image

16 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I'm afraid there isn't currently a way of achieving this via Blueprints, I could help you out with a C++ approach if that's something you could use.

I've added a TTP (#339865) to add this feature as it does seem like something that could be useful and asked for again.

more ▼

answered Jun 26 '14 at 01:17 PM

avatar image DrunkCompiler Jun 26 '14 at 02:03 PM

Yes please, I'm quite capable of using C++ (just not for the project I'm currently working on), any help would be appreciated. Thanks.

avatar image IdentityCrisisUK STAFF Jun 26 '14 at 02:12 PM

Okay, I posted pretty much the same thing in answer to this forum thread the other day: https://forums.unrealengine.com/showthread.php?7936-Custom-Music-Player

You can use FAudioDevice::FindActiveSound to get the FActiveSound associated with the audio component while it's playing. Then you'd have to use the map of FWaveInstances the active sound has (should only be one when playing a sound wave) and use the Audio Devices WaveInstanceSourceMap to get the sound source associated with it.

You can pause a Sound Source though there is one caveat in that if you pause and unpause the game, FAudioDevice::HandlePause will currently restart all sounds unless they are tagged with bIsUISound. I don't know if setting your sound to be a UI Sound is an acceptable way to work around this issue for now. If pause is eventually exposed to Blueprints we will have to add a way to differentiate between manually paused sounds and those paused by the game.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question