Corona SDK Pro Tip of the Day #30
User's own background music
Allow users to listen to their own background music (apps that play music even when hidden). That currently works on iOS only.
To do so make sure you have "Music off" button in your app or game. Then paste this code at the very top of your
require('audio') if audio.supportsSessionProperty then audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode) end
If you don't put it at the top and something else accesses audio before calling
audio.setSessionProperty(), it will not work the correct way.
Instead, it will silence user's background music when your app is launched, but it will let it play if your app resumes from suspend. Therefore keeping it at the top of
main.lua is very important.