How to make an Runtime event still running even if app is suspended

I was testing something to make my app still run while in suspended mode, so I tried playing a song even if the app is suspended/sleep(just like in an mp3 player)

so here is my code : 

gameMusic = audio.loadStream("Blue Chase\_0.mp3")     gameMusicmenu = { loops = -1}     musicCaller = audio.play(gameMusic, gameMusicmenu) local function onSystem(event) if event.type == "applicationStart" then print("start") elseif event.type == "applicationExit" then print("exit") elseif event.type == "applicationSuspend" then print("suspend") elseif event.type == "applicationResume" then print("resume") end end Runtime:addEventListener( "system", onSystem )

I just want to keep it playing even If i press home/back in android, suspend in simulator, and home in iOS, but whenever I do that the song pause,

Corona SDK requires the User Interface to be in the foreground for any of it’s API calls to work.  Because of this, it’s possible to play backgrounded audio on iOS only assuming that you are not doing anything else.  There is no accessing the GPS for events and even the one mode that kinda works is not supported.   None of it works on Android.

If you wish to have a backgroundable app, you will need to do it in a native development environment.

Rob

native development environment? what do you mean by that? at least for iOS I can make my app still run in background.

Native development environment: Xcode + Objective C for iOS, Java for Android

Right thanks :slight_smile: Glad I found this already. Are there anyway to integrate Corona with this? It was just one feature on my app that will make me force to change development environment. I was hoping using corona all the way

If you just want to background audio, then you don’t need to have the UI active, and you should be able to get it to work, however, and I can’t re-iterate this enough.   Corona Labs does not support backgrounded apps.  The ability to do what you’re doing could change at any time and without notice.

Corona SDK requires the User Interface to be in the foreground for any of it’s API calls to work.  Because of this, it’s possible to play backgrounded audio on iOS only assuming that you are not doing anything else.  There is no accessing the GPS for events and even the one mode that kinda works is not supported.   None of it works on Android.

If you wish to have a backgroundable app, you will need to do it in a native development environment.

Rob

native development environment? what do you mean by that? at least for iOS I can make my app still run in background.

Native development environment: Xcode + Objective C for iOS, Java for Android

Right thanks :slight_smile: Glad I found this already. Are there anyway to integrate Corona with this? It was just one feature on my app that will make me force to change development environment. I was hoping using corona all the way

If you just want to background audio, then you don’t need to have the UI active, and you should be able to get it to work, however, and I can’t re-iterate this enough.   Corona Labs does not support backgrounded apps.  The ability to do what you’re doing could change at any time and without notice.