Wednesday, 20 November 2013

How to play background music in corona SDK application

This is a simple tutorial, which will teach you how to play background music in your corona SDK applications. 

First, load the music as:
  local backgroundMusic = audio.loadStream("bgMusic.mp3") 

Then you can play the music in loop as:

  local backgroundMusicChannel = audio.play( backgroundMusic, { channel=1,
                                                                                                              loop    s=-1,   
                                                                                                              fadein   =5000 })


where, channel is an integer value representing the music channel (0-32)

And if you want to stop the music, you can use:
  audio.stop( backgroundMusicChannel )

No comments:

Post a Comment