# Playing audio after one completes ?

**URL:** <https://forums.unrealengine.com/t/playing-audio-after-one-completes/583008>\
**Category:** Audio\
**Tags:** unreal-engine, UE4, question\
**Created:** [June 16, 2022, 1:42am UTC](https://forums.unrealengine.com/t/playing-audio-after-one-completes/583008 "2022-06-16T01:42:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinayakvs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vinayakvs](https://forums.unrealengine.com/u/Vinayakvs)\
**Post date:** [June 16, 2022, 1:42am UTC](https://forums.unrealengine.com/t/playing-audio-after-one-completes/583008/1 "2022-06-16T01:42:41Z")

</div>

Hey Guys, I am currently working on a project which requires me to add audio (Background Music) to the game. I would like to know what I should do so that after a random audio cue is played, another random cue will be played from the track.

I want to make it like background music playing one after another.

 ![Screenshot 2022-06-16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/c/03c0f4d7402cb31f7cbe7450249efa2f3ee56f16.png)  
 ![Screenshot (2) 2022-06-16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/a/d7aa24663795ac48155760e87e90004a2ed68098.png)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [June 16, 2022, 3:23am UTC](https://forums.unrealengine.com/t/playing-audio-after-one-completes/583008/2 "2022-06-16T03:23:27Z")

</div>

You can bind a function to “OnAudioFinished” on the AudioComponent created when you use CreatesSound2D. In that function you can play the next song.

---

<div class="post-metadata">

**Author:** ![Featuriing](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/featuriing/32/1135409_2.png) [@Featuriing](https://forums.unrealengine.com/u/Featuriing)\
**Post date:** [June 16, 2022, 7:48am UTC](https://forums.unrealengine.com/t/playing-audio-after-one-completes/583008/3 "2022-06-16T07:48:46Z")

</div>

You can also just create one sound cue, add a “random” node to it and add all your music tracks to that one. Looping this cue will then play random music for ever without the need of any extra programming. Just play it once and forget about it 😁

---

<div class="post-metadata">

**Author:** ![eagletree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eagletree](https://forums.unrealengine.com/u/eagletree)\
**Post date:** [June 16, 2022, 7:20pm UTC](https://forums.unrealengine.com/t/playing-audio-after-one-completes/583008/4 "2022-06-16T19:20:13Z")

</div>

A third approach, needed if you choose to move forward with a MetaSoundSource, would be to use an MS random node to generate a number to select out of a WaveAsset array. The WaveAsset array would contain all your waves. The number would be used in a Get and fed into the Wave Player node (specifically the Wave Asset input). The OnNearlyFinished output of the WavePlayer, would set a Trigger variable. You would pull off a Delayed version of that variable to trigger the WavePlayer-\>Play, the Random number generation trigger, and the Get Array node.

To start it initially, you would have hook the OnPlay input to all of those same nodes the delayed variable trigger is connected to. This would involve using a Trigger Any node.

Using this approach, all the logic goes in the MetaSoundSource with the BP only starting the MetaSound. This can be set up to run across levels and loading screens too.

Edit: I remembered that there is an example that @lantz.anna_1 posted in this thread. It is a screen shot showing the use of exactly what you are looking for and is about 5 posts from the bottom:

> [@Setting Metasounds Variable](https://forums.unrealengine.com/t/setting-metasounds-variable/508262/18):
>
> What you may have found would explain why I had to drop using Quartz Play Quantized. I mentioned this in another thread and it was suggested not to use Quartz but make the MS Standalone. This didn’t work well because controlling the waves from within a MS becomes impossible because of loop detection. You can’t use the outputs from a wave to control the stop of that wave and working around that creates indecipherable MS graphs. But originally I was attempting to use Quartz. My finding was that I…
