Love bgmusic

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
adrywalsh
Prole
Posts: 20
Joined: Fri Feb 26, 2010 7:24 am

Love bgmusic

Post by adrywalsh »

I'm trying to make any sensible way of playing background music with the option of letting the user stop it in-game.

Code: Select all

if key == "m" then
    love.audio.play(bgmusic)
end
This above works fine for me. If I press "m" then the music starts, and it is fantastic.

However if I make any attempt to have a function available to stop the bgmusic, it will no longer start. For example if I simply add:

Code: Select all

if key == "n" then
    love.audio.stop()
end
then I will only hear the first one second of the audio when I press "m." I am not pushing "n."

There is no other change being made to the code. The audio source is a .ogg and is set to "stream."
I do not understand why a condition that hasn't been met has some effect on the rest of the program.

Maybe there is a better function to manage by audio activity?
while (1)
do LÖVE
User avatar
adrywalsh
Prole
Posts: 20
Joined: Fri Feb 26, 2010 7:24 am

Re: Love bgmusic

Post by adrywalsh »

Another fun fact:
If I do not press "m" before another sound occurs, the music will not start.
while (1)
do LÖVE
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 4 guests