I’m doing the cross scene audio with the sfx.lua module as described in this article:
http://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/
I load and play my narration and bg sounds in enterScene. resetNarration function is to rewind
the narration and make sure it’s at full volume.
[lua]
function scene:enterScene( event )
local group = self.view
storyboard.removeAll() --attempt to remove previous scenes
local narration = audio.loadStream( “narration/narrationPage07.mp3” )
------------Reset Audio------------------------------
local function resetNarration(event)
if event.completed == false and event.phase == “stopped” then
audio.setVolume ( 1, {channel=1 })
audio.rewind (narration)
end
end
----- Play Audio Clips --------------
local function playNarration()
audio.play(narration,
{
channel=1,
loops=0,
onComplete=resetNarration } )
end
playNarration()
[/lua]
and then I stop, dispose and nil out the handle in exitScene:
[lua]
function scene:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
-----unload Audio-------
audio.stop(1)
audio.dispose( narration )
narration=nil
---------cancel timers and transitions-------
transition.cancel ()
Runtime:removeEventListener ( “enterFrame”, followCelia )
end
[/lua]
I have changed the code to load the sounds instead of trying to use audio.loadStream. That seems to have fixed the problem
I was having. It always worked the first time through the story??? That is why I don’t get it. After it would finish and go
back to the main start page, about half way through the book it stops playing the narration.
I will switch to composer after this one. It is ready to go up on the store now. Looking good! Thanks for all your help!