SBM SBM - 1 year ago 65
iOS Question

AVAudioPlayer doesn't play audio after the home button is pressed

I'm new in ios development.I'm using AVAudioPlayer.The audio plays in foreground. After that when i tapped the home button the app comes to background but the audio was muted.

Answer Source

Try this,

- (void)applicationDidEnterBackground:(UIApplication *)application
__block UIBackgroundTaskIdentifier task = 0;
task=[application beginBackgroundTaskWithExpirationHandler:^{
    NSLog(@"Expiration handler called %f",[application backgroundTimeRemaining]);
    [application endBackgroundTask:task];