Streaming audio with app in background/suspended

Hi, 

is it possible to continue streaming audio from a network resource while the app is suspended/in the background?

On native iOS, this is possible - see “Playing Background Audio” - but I’m wondering if and how Corona supports this.

Thanks,

Thomas

Bump.

I want this too

Lua is not background safe.  On Apple iOS you can get audio to play while it’s sleeping in some circumstances, but going forward, it may not work.  If you get it to work, it’s unsupported and if we break you, there isn’t much we can do about it.

Hmm interesting. But since you’re embedding Lua shouldn’t you be able to wrangle anything from the Obj-C side? I realize, of course, that you don’t currently support it, but shouldn’t it be possible to implement in the future?

I have successfully used background audio in published apps.

Use this code in build.settings …

settings = {         iphone =         {                 plist =                 {                         UIBackgroundModes =                          {                             "audio",                         },                         UIApplicationExitsOnSuspend = false,                 },         }, }  

and in your lua code …

-- set this propoerty to allow audio to continue playing when app suspended/screen locked or silent switch on -- N.B. this API is subject to change -- need to do this before any other audio calls -- N.B. this does not work in the Corona simulator only in iOS simulator or device if audio.supportsSessionProperty then     --print("setting audio to allow play to continue on suspend")     audio.setSessionProperty(audio.OverrideMixWithOthers, audio.MediaPlaybackMixMode) end  

This has been working for quite a while - and still works with the iOS7 beta on my iPhone4S - but as Rob says, no guarantee that it won’t break in the future! You’ll find a lengthy thread about the audio session properties and the process i went through to get this to work here …

http://forums.coronalabs.com/topic/8742-new-audiosession-properties/

Stefan

Thanks for the example! I’ll be giving this a try.

Bump.

I want this too

Lua is not background safe.  On Apple iOS you can get audio to play while it’s sleeping in some circumstances, but going forward, it may not work.  If you get it to work, it’s unsupported and if we break you, there isn’t much we can do about it.

Hmm interesting. But since you’re embedding Lua shouldn’t you be able to wrangle anything from the Obj-C side? I realize, of course, that you don’t currently support it, but shouldn’t it be possible to implement in the future?

I have successfully used background audio in published apps.

Use this code in build.settings …

settings = {         iphone =         {                 plist =                 {                         UIBackgroundModes =                          {                             "audio",                         },                         UIApplicationExitsOnSuspend = false,                 },         }, }  

and in your lua code …

-- set this propoerty to allow audio to continue playing when app suspended/screen locked or silent switch on -- N.B. this API is subject to change -- need to do this before any other audio calls -- N.B. this does not work in the Corona simulator only in iOS simulator or device if audio.supportsSessionProperty then     --print("setting audio to allow play to continue on suspend")     audio.setSessionProperty(audio.OverrideMixWithOthers, audio.MediaPlaybackMixMode) end  

This has been working for quite a while - and still works with the iOS7 beta on my iPhone4S - but as Rob says, no guarantee that it won’t break in the future! You’ll find a lengthy thread about the audio session properties and the process i went through to get this to work here …

http://forums.coronalabs.com/topic/8742-new-audiosession-properties/

Stefan

Thanks for the example! I’ll be giving this a try.