music loop stoping help

I just finished implementing the music into the game I am working on and got the music to loop correctly and loop without skipping. Now though after a world is completed and the game goes back to the map the music is supposed to stop but continues and plays over the other music that is supposed to be playing. We think it has to do with the timer we have set for the loops but we are not sure on solutions for it. I can post some code if anyone would like a look to help them. Thanks for helping in advance!

Hi

You shouldn't use a timer to loop the music, you should use something like this:

loop1=audio.loadSound('loop.mp3')
musicLoop = audio.play(loop1,{channel=1,loops=-1})

You can especify the channel so no other audio or sound hits your music channel, and you send the loops=-1 to loop it forever...

If you ever want to pause the music then you can use the variable as you set it in my example it is:

audio.pause(musicLoop)

and then to resume:

audio.resume(musicLoop)

I hope that helps you out...

Regards

what the timer was for is that we need the music to also be able to start from any level as well as continue to loop if already started.

That's why i told you the audio.pause and audio.resume... if you start the level: audio.resume, if you close the level and want another music or something, or you opened the menues, you can use audio.pause. Then when you are back to the level you use audio.resume and it gets back to what was playing...

No need for any timer. Timers consume a lot of resources you should avoid them when you can.

Thats my 2 cents.

I see what you are saying, but I'm not sure if that is the best choice in this situation. From any level in the world we need the music to be able to start from the map and continue to play through out the rest of the world until the end.

Well, on main.lua, you start the loop, on world end you pause the loop, on back to map or new level you resume the loop., if you don't need it to stop ever just put audio.play with the loop=-1 and that will play until you exit the game. (or if you play anything else on the same channel)

thanks for your help we gave it a try and it has worked perfectly so far with no flaws!

Your welcome

views:1725 update:2011/12/29 9:44:01
corona forums © 2003-2011