Is there a way to disable all of the app’s audio and let the device’s music library play? What happens in mine is that when I play music or a podcast in my library then start my app, the music stops. [import]uid: 144908 topic_id: 28969 reply_id: 328969[/import]
anyone? [import]uid: 144908 topic_id: 28969 reply_id: 116780[/import]
On iOS, either never call any audio.* APIs which should avoid initializing the audio system or use the (advanced) Audio Session APIs to allow mixing with the iPod music player. See the link for Audio Sessions on the Audio Notes page.
[import]uid: 7563 topic_id: 28969 reply_id: 116796[/import]
I’ve looked at these notes and secret documentation and my brain gets real fuzzy, real fast.
It looks like Corona has the capability to reserve 1 or 2 channels for the apps sounds and allow the iOS device music library to play in the background.
I’d really like to do this.
Is there any chance there could be a sample/tutorial of the code that would accomplish this, as it seems very complicated and would be a great option/feature for developers to utilize.
I’ve researched this topic and was surprised how little there is available on it. It just seems to me, if Corona can accomplish this, then it would be great to exploit it.
Nail
[import]uid: 106779 topic_id: 28969 reply_id: 116814[/import]
Yes, those APIs are intended for advanced usage only. You should read Apple’s documentation on Audio Sessions for a better understanding.
But that thread already has the code you need. You just need to set a mode that allows ‘mixing’. You don’t need to do anything else. You don’t need to reserve channels for the other iPod or anything else. The OS takes care of everything once you opt into mixing.
[import]uid: 7563 topic_id: 28969 reply_id: 116952[/import]
ewing wrote:
You just need to set a mode that allows ‘mixing’.
Thank you for following up ewing, I was certainly overwhelmed by the post. I’m just a wanna be newb and the options/variables that can be specified with the sound engine was to much for me to grasp without some serous reviewing.
I’m almost ready to submit my app and would really like to allow the “on device” music library to be played in the background. I’ll go back and re-read/absorb the info and concentrate on anywhere “mixing” is mentioned.
While attempting to transition from a builder of homes to a builder of Apps, after 7 steep months of learning to program with Lua, Corona SDK, PubNub, Corona MultiPlayer, basic PHP, Provisioning Certificates, iTunes Connect, basic Xcode funtionality, IAP, IAP verification, BIS Encryption Registration, basic mySQL, basic HTML, I guess if it takes me a few more days to get “what I’m after” wont’ kill me.
I probably should have started with a simple “Burp Me” app. 
Thanks again for the tip.
Nail [import]uid: 106779 topic_id: 28969 reply_id: 116974[/import]
Thanks Ewing!
I ended up enabling mixing with the ipod audio when the app starts, then the game’s setting for enabling/disabling background music (technically just a 0.0-1.0 volume control) is just automatically set to off when an ipod audio is detected to be currently playing.
For future reference and for other people who need this as well, here’s the code I’m using:
main.lua
[lua]-- at the start of the app, make sure external audio won’t stop
if audio.getSessionProperty then
audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)
end
–[[your other startup code]]–
– if on start and there is an external audio playing, stop our background music
local function updateMusicSettingOnExternalAudio()
if audio.getSessionProperty then
if audio.getSessionProperty( audio.OtherAudioIsPlaying ) == 1 then
–[[turn off audio here and save your game settings]]–
end
end
end
– if when resumes and there is an external audio playing, stop our background music
local function onSystemEvent( event )
if event.type == “applicationStart” or event.type == “applicationResume” then
updateMusicSettingOnExternalAudio()
end
end
Runtime:addEventListener( “system”, onSystemEvent )[/lua] [import]uid: 144908 topic_id: 28969 reply_id: 117463[/import]