This question is not a duplicated post of this one UIWebView: HTML5 audio pauses in iOS 6 when app enters background
I can access to the track from the control center but the audio is stopped. How avoid the pause state, or how replay the track in the background thread?
All my code is here. You can paste the code in the AppDelegate of a new empty ios app
- Add AVFoundation Framework
- Enable Background Audio
I's does not work, it's appear in the control center, but music is paused when the app enter in Background!
#import "AppDelegate.h" #import <AVFoundation/AVFoundation.h> @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. AVAudioSession *audioSession = [AVAudioSession sharedInstance]; BOOL ok; NSError *setCategoryError = nil; ok = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]; if (!ok) { NSLog(@"%s setCategoryError=%@", __PRETTY_FUNCTION__, setCategoryError); } UIViewController *vc = [[UIViewController alloc] init]; UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController: vc]; self.window.rootViewController = nav; //WEBVIEW UIWebView *myWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 200, 320, vc.view.frame.size.height)]; myWeb.mediaPlaybackRequiresUserAction = NO; myWeb.allowsInlineMediaPlayback = YES; [vc.view addSubview:myWeb]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://www.romito.fr/public/inlineHTML5/"]]; [myWeb loadRequest: request]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }