#Dealing with overlapping music for same song when pressing P key

28 messages ยท Page 1 of 1 (latest)

grave pumice
#

you've got the right general idea, but it should be the reverse

#
if !(audio_is_playing(HOME))
{
    audio_play_sound(HOME,1000,true)
}
else {
    audio_stop_sound(HOME);
}
``` first, don't play the audio if it's not already playing. Otherwise, stop it if it's already playing
#

the else is important here, otherwise it would start playing the sound and then immediately stop playing it in the same press

sudden ibex
#

it still happens p-p

#

this is a video of the pain

grave pumice
#

oh, I just saw you wanted to press o to stop the track instead of p to toggle

#

in that case

#
{
    audio_play_sound(HOME,1000,true)
}
``` in p press
#
audio_stop_sound(HOME);
``` in o press
sudden ibex
#

No just pressing p more than once making the music overlap with the same track instead of doing nothing (like it should).
So making sure it can only be pressed once, playing the music so nothing like the video happens and o stops the track already so don't worry about that
-basically I just want p to only play the song once and when it's playing not to overlap with said song if i press p again so cancel it out if were to press it when the song is playing.

grave pumice
#

can you show what your p press code is right now?

sudden ibex
grave pumice
#

The code I posted should do that, by checking if the sound is not already playing

#

That video doesn't embed, I can't watch it without downloading it

sudden ibex
#

wait one sec

grave pumice
#

I know what happens, what is your code now? Has it not changed from what you originally posted?

sudden ibex
#

No not really stuck

grave pumice
#

I posted what code you can use to fix it twice

#

I can post it again if you want if !(audio_is_playing(HOME)) { audio_play_sound(HOME,1000,true) }

sudden ibex
#

๐Ÿ’€

grave pumice
#

Can you show what your code is now?

sudden ibex
#

one sec

grave pumice
#

You're also playing the sound unconditionally on line 1

#

need to remove that