Importing to Xcode: music still plays while app is in the background

I want to try to get my daughter’s adventure games onto the app store.

I’ve imported my app to Xcode, and it mostly runs great.

One thing though: I play looping music in my app, and when the app goes to the background (like when you switch apps or leave an app and go to the home screen) the music keeps playing.

How do I make the music mute itself when the app is in the background, and then turn itself back on when it becomes the main app again?

@UberGoober I use music() on setup function, did you try this?

I call music(foo) in a different function than that. Should it matter?

I think it’s important for Codea apps to be able to detect when this event (along with the close event) happens so we can ensure the app state is set correctly.

If I make that edit in Xcode will it work? Or do I have to do it in Codea and then re-import it?

@UberGoober , you can edit in xCode

I just put music(filename,true,1) in setup and it works fine.

Is it then the case that any looping music has to start from the beginning of the program and play without interruption for it to behave properly?

If one starts it at any other time it won’t behave?

@UberGoober, I use looping music in my exported projects (not called from setup), and if you exit the app it keeps playing for a few seconds, but then it fades out.

Hm. I’ll have to test it on different ipad simulators. Maybe it’s just a problem with the iPad Air Simulator.