Soundtrack and Storyboard

Hi.

I’m beginning to make an app game, something like Mosaika, but I’m a newbie.

The structure of the game is based on storyboard.

I’d like to have a soundtrack that sounds continously through every scenes, but I didn’t find any method to do that.

Any helps is appreciated.

Thanks!

If you setup your audio stream to play continuously, it will play continuously regardless of storyboard scene.

Use audio.loadStream() to put your music file into memory

Use audio.play() and use loops = -1 to infinitely loop the music

OK, thanks.

But now how can I stop it in some other scene. What is the reference to that soundtrack?

I do the following to start playing my background music

local myMusic local bgMusic = audio.loadStream("loop.mp3") myMusic = audio.play( bgMusic, { channel = 1, loops = -1 } )

then to stop it

audio.stop( 1 ) audio.rewind( 1 )

the (1) refers to the channel that is set in the first block. I use the audio.rewind part so that my loop goes back to the beginning just in case the user starts the sound back up again

Perfect.

You’ve been very kind.

where do you put the 

local myMusic
local bgMusic = audio.loadStream(“loop.mp3”)

myMusic = audio.play( bgMusic, { channel = 1, loops = -1 } )

I want my music to be playing right when I start the game

I’m not an expert. Anyway I tried the code above inside the function scene:createScene( event ) (I’m using storyboard).

In an other scene, always in the function _ createScene, _ I stopped it with the following code

audio.stop( 1 )

P.S.: 1 refers at the number of the channel

Also to remove audio from the storyboard use, I took my a while to find it.

function scene:exitScene(event)

    background:removeEventListener(“touch”, start)

    storyboard.purgeAll( )

    storyboard.removeAll( )

    audio.stop(1) --stop audio channel=1

end

If you setup your audio stream to play continuously, it will play continuously regardless of storyboard scene.

Use audio.loadStream() to put your music file into memory

Use audio.play() and use loops = -1 to infinitely loop the music

OK, thanks.

But now how can I stop it in some other scene. What is the reference to that soundtrack?

I do the following to start playing my background music

local myMusic local bgMusic = audio.loadStream("loop.mp3") myMusic = audio.play( bgMusic, { channel = 1, loops = -1 } )

then to stop it

audio.stop( 1 ) audio.rewind( 1 )

the (1) refers to the channel that is set in the first block. I use the audio.rewind part so that my loop goes back to the beginning just in case the user starts the sound back up again

Perfect.

You’ve been very kind.

where do you put the 

local myMusic
local bgMusic = audio.loadStream(“loop.mp3”)

myMusic = audio.play( bgMusic, { channel = 1, loops = -1 } )

I want my music to be playing right when I start the game

I’m not an expert. Anyway I tried the code above inside the function scene:createScene( event ) (I’m using storyboard).

In an other scene, always in the function _ createScene, _ I stopped it with the following code

audio.stop( 1 )

P.S.: 1 refers at the number of the channel

Also to remove audio from the storyboard use, I took my a while to find it.

function scene:exitScene(event)

    background:removeEventListener(“touch”, start)

    storyboard.purgeAll( )

    storyboard.removeAll( )

    audio.stop(1) --stop audio channel=1

end