No audio playing after suspend/resume on build 540

So, basically before the build 540 (<539), when my app was suspended (lock the screen or double click the home button to open the background app list) the audio stopped, and started playing again when the app was resumed.

On build 540 however it looks like when the app is resumed the audio doesn’t work anymore. I’ve tried audio.dispose and loading again but it gives me a “WARNING: Failed to create audio sound” error.

(using audio.loadSound and audio.play)
PS: Basically, I was testing the audioSession and ios backgrounding in 540 beta. It was working nicely, however the sound sometimes stopped playing. So I removed all the audioSession/background functions and tested the basic app with 540 and 539.
[import]uid: 9158 topic_id: 11283 reply_id: 311283[/import]

I can verify this too.

Just compiled with 540 and same thing happens, no sound when coming back from the suspend.

I’m using UIApplicationExitsOnSuspend = false

Going back to previous build for now… [import]uid: 10478 topic_id: 11283 reply_id: 40978[/import]

I hope this gets fixed. I just read about this in the daily builds and came here to post about HOW EXCITED I AM for this to finally be implemented.

So, I’ll say it here: I am SO EXCITED for the ability to come back from suspend. :slight_smile:

Please make it work right. :smiley:

THANKS! [import]uid: 13859 topic_id: 11283 reply_id: 40997[/import]

Yes, 539 is OK.

Just to make sure, I’ve even set the UIBackgroundModes key in plist (with 540 of course), result is still the same. [import]uid: 10478 topic_id: 11283 reply_id: 41091[/import]

Ok yeah - so just my test on this the issue is specifically with the LOCK button … and not the multitask switching.

Double-Tap home button app switching and the sound works fine.

Press the lock button and then unlock back to the app and there’s no sound anymore.

But the double-tap multitask is friggin awesome. Small thing, big excitement. :slight_smile:

Dramatic Music App Plus is just umpteen times cooler when you can keep it loaded and don’t have to wait for loading when the right situation presents itself. *cue shameless plug of SOON TO BE multi-taskable app* http://itunes.apple.com/us/app/dramatic-music-app-plus/id429111758?mt=8

:wink:

[edit for typo]
[import]uid: 13859 topic_id: 11283 reply_id: 41138[/import]

(And right, the lock screen / resume works correctly in 539. This just happens in 540. [import]uid: 13859 topic_id: 11283 reply_id: 41139[/import]

And just to update, just tapping the home button to go back to the home screen loses the audio too. the only thing that does work is double-tap home button, go to another app, and then double tap to go back to the original app. that works fine. home and then double tap back to the app and no sound.

… and i’m using:
UIApplicationExitsOnSuspend = “NO”,
UIBackgroundModes ={ “audio” },

… also tried without background mode … same issues.

[import]uid: 13859 topic_id: 11283 reply_id: 41140[/import]

I’m always on the bleeding edge builds, so I’m glad to know I wasn’t coding wrong when I was experiencing this issue.

Knock on wood, it’s the first bug I’ve ever experienced in a newer build. Your Kung Fu is strong, Ansca. [import]uid: 6084 topic_id: 11283 reply_id: 41169[/import]

Appears to be fixed on build 544 :slight_smile: [import]uid: 10478 topic_id: 11283 reply_id: 41277[/import]

Yes, works in 544 as expected.

AWE-SOME. Love it. So exciting.
:slight_smile: [import]uid: 13859 topic_id: 11283 reply_id: 41292[/import]

Please be aware, the backgrounding feature is incomplete and it is not officially supported yet. We still reserve the right to completely break any apps that use this feature and we do not want to see any bug reports with test examples that use any unsupported features.

There are hard limitations in using it, most notably that while the underlying audio engine will continue to play, the Corona core still suspends. This means event callbacks (like onComplete) will not fire until the app is resumed. The main reason we do this is because any attempt to make (OpenGL) drawing calls on iOS while backgrounded will result in iOS killing your process and likely App Store rejection. And attempting to do more processing that what is deemed appropriate by Apple will also be grounds for App Store rejection. So we feel we need to design/implement more constrained rules/APIs to manage and cooperate within Apple’s expectations of backgrounding.

[import]uid: 7563 topic_id: 11283 reply_id: 41299[/import]

@ewing: No worries from me… I just want the ability for someone to double-tap out of my app and be able to double-tap into it without waiting the 4 to 7 seconds for it to “reboot” itself.

For our practical use, I’ve turned it on with our “Writing Prompts” app and “Dramatic Music App”.

Dramatic Music App does have loops, and they do successfully keep playing when you background the app. That’s great and I hope that continues to work, but the non-load time when switching back to the app is most exciting. For example, you can then use the app to play a funny dramatic music piece BEFORE the moment in the conversation has passed… prior to this, it’s more like “wait a minute while i load the app … pause … ok, now here’s the funny sound.” :wink:

Likewise, with Writing Prompts, the benefit has nothing to do with anything running in the background … and is the simple act of being able to keep the Writing Prompts open, double-tap over to the “Notes” or “Email” application and then double-tap back over to the Prompts app while it’s still open and in the same state, without any wait time for re-loading.

The only “code” I’m using is the change to info.plist to not exit the app on suspend. I think it’s awesome. :slight_smile: (Have I said that?)

So, **pretty please** … if you break it, do leave the basic functionality of being able to use this very basic backgrounding. :wink: And do keep in mind that a lot of are writing more simple apps that don’t use OpenGL and the like… so real simple support for this is all we need and it’s still a huge leap forward.

Thanks! :slight_smile:
~~Kenn [import]uid: 13859 topic_id: 11283 reply_id: 41307[/import]

Quick notes:
If you only care about fast suspend and resume, defining:
UIApplicationExitsOnSuspend = false
without setting UIBackgroundModes to anything should be sufficient.

UIBackgroundModes is only to request processing while background and is subject to additional Apple scrutiny in the review process.
Also, if you only care about music playing during screen lock but not backgrounding, instead of setting UIBackgroundModes, you might just try setting the mix mode to audio.MediaPlaybackMixMode.

[import]uid: 7563 topic_id: 11283 reply_id: 41639[/import]

Hi ewing,

I’ve just noticed following error in device console

unknown 3[1976] : Error setting audio session active to 0! ‘!act’

3 is the app name and I’ just using fast suspend (UIApplicationExitsOnSuspend = false)

That happens when the app goes into the suspend, tested with 544 & 545 [import]uid: 10478 topic_id: 11283 reply_id: 41792[/import]

Minor changes related to this just went in today. It *might* go away.

Let me know if these problems are actually breaking audio or just annoying messages.
[import]uid: 7563 topic_id: 11283 reply_id: 41799[/import]

Yesterday I noticed the same “Error setting audio session active to 0! ‘!act’” on 544 and 545, happening in the suspending/resuming phase.
I’ll check with the latest build.
[import]uid: 9158 topic_id: 11283 reply_id: 41804[/import]

Just tested with build 547, unfortunately it didn’t go away yet… Same msg on both iPad & iPhone4.

Suspend appears to be workingbut when resuming after app is full screen there appears to be a momentary lag (on both animation & sounds). I don’t remember noticing that before… [import]uid: 10478 topic_id: 11283 reply_id: 41883[/import]

So I just retested on 547 with the following code.

local function onSuspend( event )  
 print("In onSuspend", event.type)  
 if event.type == "applicationSuspend" then  
  
 elseif event.type == "applicationResume" then  
  
 end  
end  
  
Runtime:addEventListener( "system", onSuspend )  
  
music = audio.loadStream("background.mp3")  
audio.play(music, {channel = 1, loops=-1})\  

I see the error message only when I run the app normally, but not when I run through the Xcode debugger. Very strange. It doesn’t seem to hurt anything for me though which is what I’m more concerned about. (Apple goofed here and they don’t have an API to query the current active state so I have to take a leap of faith and set the value even if the value has already been set which seems to return an error in this case.)

I don’t experience the resuming hiccup, but my test case may too simple.

[import]uid: 7563 topic_id: 11283 reply_id: 41964[/import]

Just tested your code on 549, it’s still there but nothing major I guess…

Also forget about the hiccup, just tested Angry Birds and same hiccup is there both for sound & graphics. Does not happen at the first time or all the time, so it looks like an apple thing… [import]uid: 10478 topic_id: 11283 reply_id: 41997[/import]

@ewing

That error appears to be back at latest daily build CoronaSDK 2011.610

I just have UIApplicationExitsOnSuspend = false set in my build.settings

If I also set UIBackgroundModes = { “audio” }, that doesn’t happen but of course game music keeps playing…

I will try it with latest stable release… [import]uid: 10478 topic_id: 11283 reply_id: 54081[/import]