Adding background music

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
michaeladair
Prole
Posts: 9
Joined: Mon Dec 29, 2014 5:12 am

Adding background music

Post by michaeladair »

Basically I want to add some background music to my game.
I found:

Code: Select all

source = love.audio.newSource( file, type )
And

Code: Select all

love.audio.play( source )
Do I just make it like this?

Code: Select all

music = love.audio.newSource( libs/gangstersparadise, mp3 )
love.audio.play( music )
Any help would be great, thank you.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Adding background music

Post by s-ol »

michaeladair wrote:Basically I want to add some background music to my game.
I found:

Code: Select all

source = love.audio.newSource( file, type )
And

Code: Select all

love.audio.play( source )
Do I just make it like this?

Code: Select all

music = love.audio.newSource( libs/gangstersparadise, mp3 )
love.audio.play( music )
Any help would be great, thank you.

Code: Select all

music = love.audio.newSource( 'libs/gangster paradise.mp3', 'dynamic' )
music:setLooping( true ) --so it doesnt stop
music:play()

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
michaeladair
Prole
Posts: 9
Joined: Mon Dec 29, 2014 5:12 am

Re: Adding background music

Post by michaeladair »

S0lll0s wrote:
michaeladair wrote:Basically I want to add some background music to my game.
Any help would be great, thank you.

Code: Select all

music = love.audio.newSource( 'libs/gangster paradise.mp3', 'dynamic' )
music:setLooping( true ) --so it doesnt stop
music:play()
It says that dynamic is an invalid source type...
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: Adding background music

Post by Doctory »

don't do dynamic.
User avatar
michaeladair
Prole
Posts: 9
Joined: Mon Dec 29, 2014 5:12 am

Re: Adding background music

Post by michaeladair »

Doctory wrote:don't do dynamic.
Then what should I do instead of it? And should i have this code inside a function?
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

Re: Adding background music

Post by Evine »

"stream" or "static" is a thing, "dynamic" is not.

https://www.love2d.org/wiki/SourceType

Code: Select all

music = love.audio.newSource( 'libs/gangster paradise.mp3', 'stream' )
music:setLooping( true ) --so it doesnt stop
music:play()
michaeladair wrote:And should i have this code inside a function?
Either in love.load() or not in a function. (Just don't put it in love.update or love.draw)
Artal, A .PSD loader: https://github.com/EvineDev/Artal
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Adding background music

Post by s-ol »

Evine wrote:"stream" or "static" is a thing, "dynamic" is not.

https://www.love2d.org/wiki/SourceType

Code: Select all

music = love.audio.newSource( 'libs/gangster paradise.mp3', 'stream' )
music:setLooping( true ) --so it doesnt stop
music:play()
michaeladair wrote:And should i have this code inside a function?
Either in love.load() or not in a function. (Just don't put it in love.update or love.draw)
Whoops, my fault for not looking it up in the wiki again

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 1 guest