Playing music in StreamPlayer after SamplePlayer finishes sound effect

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

Hi all,

After player wins the “round” they’re taken to a screen showing them their stats.
I want to play youWonEffect sound effect.
After it finishes I want to play the youWonMusic.

Currently I have it as such:

soundSamplePlayer.play("youWonEffect")
globals.musicPlaying = load("res://audio/youWonMusic.ogg")
get_node("/root/globalsNodes/StreamPlayerMusic").play()

… and due to this it plays them both at the same time.

Now I know I could use a signal that when the soundSamplePlayer finishes playing it could trigger the music but unfortunately I use the soundSamplePlayer and the streamPlayer as a global scene so it can play across scenes and send many different music tracks and sound effects to them.

How can I then get it to play the music after the sound effect in this situation?

Advice appreciated a plenty. :slight_smile:

As a workaround you can use a timer to wait for some time, set the delay to the duration of the sound effect (you can get it from the resource, no need to hardcode that), then play the results.
If your problem is worse due to the fact you use globals, here is a personal advice: don’t use globals in this situation :slight_smile:

Zylann | 2016-11-09 13:41

:bust_in_silhouette: Reply From: Tybobobo

Here is an in-depth 5 minute long video response to your question. :3

Demonstrating two different ways of playing music after a sound effect has stopped playing
QA Answer

Woah! First of all, apologies for the delay as I’ve been tied up with the “real” job.

I cant thank you enough for such a detailed answer. It’s seriously impressive. I’ll be back in the home office in a few days and will give it a whirl.

Thanks again!

Robster | 2016-11-21 07:02