In your code, instead of:
audio.play(backgroundSound,{channel=1,loops=-1,fadein=1000}).
try:
audio.play(backgroundSound,{loops=-1,fadein=1000}
Just curious if that works? I have a question for you, because I encountered your exact issue and here is how I went about resolving it.
Using Director, and on my menu page, I had it coded this way:
local soundtrack = audio.loadStream("audio\_soundtrack.wav")
audio.play(soundtrack,{loops=-1, fadein=100})
When it switches to a new scene, the music does NOT stop, it continues to play. Then, on my back button graphic, I have it written to stop the music playing like this:
local buttonHome = display.newImage("img\_backButton.png")
function buttonHome:touch(event)
if (event.phase == "began") then
audio.fade(soundtrack) -- fades out soundtrack here!
elseif (event.phase == "ended") then
print("Home, ended phase")
timer.performWithDelay(1000, function() director:changeScene("screen1","moveFromLeft") end, 1)
end
So basically what is going on here is that the music starts on the menu scene, and on the second scene my back button first fades out the music, performs a short delay to let the music fade completely away, then switches back to the menu screen where the music then starts up again.
I tested this on an Android device (HTC Desire S) and on my iPhone and encountered a separate issue that I was hoping you could test out as well. On my Android device, if the music is still playing and I press my device’s home button the music won’t stop and will continue to play for about 4 seconds before it stops. Then when I restart the app the music sounds like it’s having a hard time playing. But with my iPhone, I have no problem at all and when I click on my iPhone device’s home button the music stops just perfectly.
Are you able to test this issue as well and let me know if you’re having the same problem? Because if yes, then I’m thinking of just not including music on my Android version but keeping the music on my iPhone version.
[import]uid: 82194 topic_id: 14630 reply_id: 54118[/import]