Page 1 of 1

Using UIBackgroundModes to play audio file

Posted: Fri Jan 04, 2013 3:44 am
by rleiman
Hi everyone,

I would like to play an mp3 file after I place the app into background mode. This file will need to be played once every hour on the hour.

Someone told me I need to use something called UIBackgroundModes but I don't know anything about how to do that.

Can you reply with a sample stack that does this?

Thanks.

Re: Using UIBackgroundModes to play audio file

Posted: Fri Jan 04, 2013 3:57 am
by Simon
I thought Guglielmo gave you the link for this info?

Simon

Re: Using UIBackgroundModes to play audio file

Posted: Fri Jan 04, 2013 5:08 pm
by gpb01
Rleiman,
I have given several times to you the link to the information you need on the Apple site ... or you STUDIES that link or you will not be able to do what you want to do ...

And, in any case, I don't know if Apple will approve a background application like the one you want to do ...
... they are very strict in approving this kind of App (... but you can still try ;) )!

Guglielmo

Re: Using UIBackgroundModes to play audio file

Posted: Sat Jan 05, 2013 11:44 am
by rleiman
Hi,

Thanks for the reply. I read the document and see it's almost like Android. I did some Android apps using basic4android and that supports putting an app in the background. I was hoping to duplicate one of my popular Android apps in LiveCode but it looks like I can't do apps like the many clock apps you can find on the Apple App Store in LiveCode.

Since they do it, I only wish to know how they did it but instead of using the C language, I want to do it in LiveCode.

I'm very new at LiveCode, if anyone can do a simple clock app stack that rings on each hour that will really be appreciated.

Re: Using UIBackgroundModes to play audio file

Posted: Sat Jan 05, 2013 3:09 pm
by gpb01
Rleiman,
this is last time that I will answer to you about this question ...

You don't wont to understand that ONLY the following kind of applications can ask iOS to run in background :

- Apps that play audible content to the user while in the background, such as a music player app
- Apps that keep users informed of their location at all times, such as a navigation app
- Apps that support Voice over Internet Protocol (VoIP)
- Newsstand apps that need to download and process new content
- Apps that receive regular updates from external accessories

... and are identified as a "Long-Running Background Tasks".

ALL other kind of App, written in LiveCode, Objective-C, or what you want, CAN ' T continue to run in background for more than about 10 mins. This type of applications can get the user’s attention using LOCAL NOTIFICATIONS.

So ... or your App is one of the Apps allowed to Run in background (... and Apple verify that you really need to do that) or you MUST use Local Notifications.

I repeat ... is NOT a LiveCode limitations, is iOS (... which is A LOT more restrictive than Android) !

Again ... all the info are very well described here :
http://developer.apple.com/library/ios/ ... sFlow.html

Guglielmo

Re: Using UIBackgroundModes to play audio file

Posted: Sat Jan 05, 2013 11:46 pm
by Simon
Hi rleiman,
Check out "Local Notifications" in the iOS release notes p.51 and:
http://forums.runrev.com/phpBB2/viewtop ... ion#p60650
I think you will find that iOS "clocks" actually do terminate and do not run in the background. Instead they tell the OS to wake them up after a set time.
Get it :D
I haven't worked with mobileCreateLocalNotification so I don't know if the app actually shows or just a badge.

Simon

Re: Using UIBackgroundModes to play audio file

Posted: Sun Jan 06, 2013 2:50 am
by rleiman
Hi Simon,

Thanks. I will experiment with the local notifications. I hope when the app wakes up it won't display any kind of dialog box.

For now I'm experimenting with MergBgTask. It allowed me to update labels but did not play the sound file so I'm still going to experiment with it for awhile.