#Dealing with overlapping music for same song when pressing P key
28 messages ยท Page 1 of 1 (latest)
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
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
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.
can you show what your p press code is right now?
๐
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
I know what happens, what is your code now? Has it not changed from what you originally posted?
No not really stuck
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) }
Can you show what your code is now?