Corona tip: iPod music & your Corona apps

December 17, 2012 at 1:31pm

Ever been curious how to keep the iPod music playing while your Corona app runs?

 

-- Set the audio mix mode to allow sounds from the app to mix with other sounds from the device        

if audio.supportsSessionProperty == true then            

print("supportsSessionProperty is true")            

audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)        

end                  

 

-- Store whether other audio is playing.  It's important to do this once and store the result now,        

-- as referring to audio.OtherAudioIsPlaying later gives misleading results, since at that point        

-- the app itself may be playing audio        

isOtherAudioPlaying = false                  

 

if audio.supportsSessionProperty == true then            

print("supportsSessionProperty is true")            

if not(audio.getSessionProperty(audio.OtherAudioIsPlaying) == 0) then            

print("I think there is other Audio Playing")                

isOtherAudioPlaying = true            

end        

end