I am building an app using PhoneGap that needs to be able to play local .mp3 files even though the phone is locked/standby. The audio player is build in HTML5, and is working fine, but the music stops when I either close the app or turn off the phone.
I tried following the answer given in this link UIWebView: HTML5 audio pauses in iOS 6 when app enters background
But no luck...
I did the import code at the top with the other import functions. And I also included the AVFoundation framework to my target.
This is how the code looks in the AppDelegate.m
/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred -iOS4 and up)
*/
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
/* THE GOOD STUFF */
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL ok;
NSError *setCategoryError = nil;
ok = [audioSession setCategory:AVAudioSessionCategoryPlayback
error:&setCategoryError];
if (!ok) {
NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError);
}
I tried in simulator and on iPhone 5.
Is anyone able to help?