audio streaming - Change station in background on iOS -


i wonder if have radio streaming app on iphone, there anyway can make app automatically switch new station while app running in background? i've heard far apple doesn't allow executed in background. events in specific states allowed running until states end.

thank much

according ios developer documentation possible.

in ios 4 , later, multitasking allows apps continue running in background after user switches app while still preserving battery life as possible. apps moved suspended state shortly after entering background. apps provide important services user allowed continue running amount of time.

as possible, encouraged avoid executing in background , let app suspended. if find need perform background tasks, here guidelines when appropriate:

you need implement @ least 1 of several specific user services.
need perform single finite-length task.
need use notifications alert user relevant piece of information when app not running.
system keeps suspended apps in memory long possible, removing them when amount of free memory gets low. remaining in memory means subsequent launches of app faster. @ same time, being suspended means app not drain device’s battery fast.

and then...

for tasks require more execution time implement, must request specific permissions run them in background without being suspended. in ios, specific app types allowed run in background:

apps play audible content user while in background, such music player app apps keep users informed of location @ times, such navigation app
apps support voice on internet protocol (voip)
newsstand apps need download , process new content
apps receive regular updates external accessories
apps implement these services must declare services support , use system frameworks implement relevant aspects of services. declaring services lets system know services use, in cases system frameworks prevent application being suspended.

and

support types of background execution must declared in advance app uses them. app declares support service using info.plist file. add uibackgroundmodes key info.plist file , set value array containing 1 or more of following strings:

audio—the app plays audible content user while in background. (this content includes streaming audio or video content using airplay.) location—the app keeps users informed of location, while running in background.
voip—the app provides ability user make phone calls using internet connection.
newsstand-content—the app newsstand app downloads , processes magazine or newspaper content in background.
external-accessory—the app works hardware accessory needs deliver updates on regular schedule through external accessory framework.
bluetooth-central—the app works bluetooth accessory needs deliver updates on regular schedule through corebluetooth framework.
each of preceding values lets system know app should woken @ appropriate times respond relevant events. example, app begins playing music , moves background still needs execution time fill audio output buffers. including audio key tells system frameworks should continue playing , make necessary callbacks app @ appropriate intervals. if app not include key, audio being played app stops when app moves background.

and

an app plays audio continuously (even while app running in background) can register background audio app including uibackgroundmodes key (with value audio) in info.plist file. apps include key must play audible content user while in background.

typical examples of background audio apps include:

music player apps
apps support audio or video playback on airplay
voip apps
when uibackgroundmodes key contains audio value, system’s media frameworks automatically prevent corresponding app being suspended when moves background. long playing audio or video content, app continues run in background. however, if app stops playing audio or video, system suspends it.

you can use of system audio frameworks initiate playback of background audio, , process using frameworks unchanged. (for video playback on airplay, must use media player framework present video.) because app not suspended while playing media files, callbacks operate while app in background. in callbacks, though, should work necessary provide data playback. example, streaming audio app need download music stream data server , push current audio samples out playback. should not perform extraneous tasks unrelated playback.

because more 1 app may support audio, system limits apps can play audio @ given time. foreground app has permission play audio. in addition, 1 or more background apps may allowed play audio content depending on configuration of audio session objects. should configure app’s audio session object appropriately , work system frameworks handle interruptions , other types of audio-related notifications. information on how configure audio session objects background execution, see audio session programming guide.

to read full documentation, go link @ beginning of answer , go heading background execution , multitasking. remember check if device on app installed has multitasking; ios4+ devices have it.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -