How do I play music on every Lua of my app even when changing scene?

Exactly as question says! 

Many Thanks,~
James

Hello JamesMallon

I did the same thing but right now i don’t remember i think

i have started some music you can say bg_Music from main.lua it self!!

You can try to load and play audio from main.lua. but exactly don’t remembering what will happen when you are changing the scene.

Thanks

If you play music in main.lua changing scene will have no effect on it, so it will carry on playing. If you want it to play forever then you need to remember to add “loops = -1” to the audio.play call.

local myBGM = audio.loadStream("myBGM.mp3") audio.play(myBGM, {loops = -1})

Thank You very much AlanPlantPot, How do I stop it with the use of a button in a separate loop file?

James

You need to save the channel it’s playing on (audio.play returns a channel) and then use audio.stop(channelnumber) when you want it to stop.

Hello,

This might be useful:

http://www.develephant.net/lets-create-a-corona-sdk-soundtrack-module-part-1/

Cheers

Hello JamesMallon

I did the same thing but right now i don’t remember i think

i have started some music you can say bg_Music from main.lua it self!!

You can try to load and play audio from main.lua. but exactly don’t remembering what will happen when you are changing the scene.

Thanks

If you play music in main.lua changing scene will have no effect on it, so it will carry on playing. If you want it to play forever then you need to remember to add “loops = -1” to the audio.play call.

local myBGM = audio.loadStream("myBGM.mp3") audio.play(myBGM, {loops = -1})

Thank You very much AlanPlantPot, How do I stop it with the use of a button in a separate loop file?

James

You need to save the channel it’s playing on (audio.play returns a channel) and then use audio.stop(channelnumber) when you want it to stop.

Hello,

This might be useful:

http://www.develephant.net/lets-create-a-corona-sdk-soundtrack-module-part-1/

Cheers