Hi this is a a test for Nook,I have a button called local audio that upon press play the sound1(audio stream)
but I have trouble figuring out how to stop the sound when I change scene using the other 3 button.
I have tried putting audio.stop and rewind in the changeScene function and it dose not respond.
I would appreciate if somebody know the answer to this:)
module(…,package.seeall)
–some code
—sound
local sound1 = audio.loadStream(“s1.ogg”);
local playsound = function(event)
audio.play(sound1,{channel=1})
end
–UI
–play the A
local audio=display.newImage(“audio.png”,_W,_H)
audio:setReferencePoint(display.CenterReferencePoint)
audio:scale(0.25,0.25)
audio.x=_W*0.5+((audio.width*0.27)/2) ;audio.y=_H*0.07
–some code
–for changing scene
function changeScene(event)
if (event.phase== “ended”) then
director:changeScene(event.target.scene);
end
end
–I have tried this .this dose not work–[[function changeScene:touch(event)
if (event.phase == “began”) then
audio.fade(sound1) – fades out soundtrack here!
elseif (event.phase == “ended”) then
print(“Home, ended phase”)
timer.performWithDelay(1000, function() director:changeScene(event.target.scene) end, 1)
end
end]]
localGroup:insert(bg1)
localGroup:insert(audio)
localGroup:insert(home)
localGroup:insert(back)
home:addEventListener(“touch”,changeScene);
back:addEventListener(“touch”,changeScene);
forth:addEventListener(“touch”,changeScene);
audio:addEventListener(“touch”,playsound)
return localGroup;
end
I have figured this out,but I still like to hear your way,to see what is better:)
thanks [import]uid: 141482 topic_id: 28788 reply_id: 328788[/import]