I know how to set up my iOS application to make it playing audio in background (= when another application is used on the iOS device) using the plist.
Some applicati
In your AppDeletate:
- (void)applicationDidEnterBackground:(UIApplication *)application {
[[YouPlayerClass sharedInstance] stop];
}
Thus The audio stops at app entering background.
Have an iVar of type UIBackgroundTaskIdentifier in the main class that handles audio playing code, initialize this with beginBackgroundTaskWithExpirationHandler.... method before starting the audio player and use endBackgroundTask when audio player completes.
Code:
@inerface AudioPlayerController : NSObject
{
UIBackgroundTaskIdentifier bgTaskID;
}
@end
@implementation AudioPlayerController
- (void) startPlayer
{
bgTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
// Write code to start the audio player
}
// Call this when your program receives message of audio playing complete
- (void) audioPlayComplete
{
// Do the audio playing finish
if (bgTaskID != UIBackgroundTaskInvalid)
[[UIApplication sharedApplication] endBackgroundTask:bgTaskID];
}
@end