iOS 9.0
I can't seem to get this running, looked at the docs, headers, it all seems fine but obviouly something is missing.
1) info.plist has the UIBackgorundModes being an array with one item "audio".
2) Using AVfoundations AVAudioPlayer.
3) Set the session category to be AVAudioSessionCatergoryPlayback
4) Set the session mode explicitly to be AVAudioSessionModeDefault (see answer from Bamsworld)
5) Implemented remote control and play now info.
6) Using notifications
But audio keeps getting paused when in background. What am I missing?
Here's the session
- (void)setupAudioSession{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
//Sugested by Bamsworld
NSError *setModeError = nil;
[audioSession setMode:AVAudioSessionModeDefault error:&setModeError];
if (setModeError) NSLog(@"mlAlbum: Error setting mode! %ld", (long)setModeError.code);
NSError *setCategoryError = nil;
[audioSession setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
if (setCategoryError) NSLog(@"mlAlbum: Error setting category! %ld", (long)setCategoryError.code);
NSError *activationError = nil;
[audioSession setActive:YES error:&activationError];
if (activationError) NSLog(@"mlAlbum: Audio session activation error.\n %ld", (long)activationError.code) ;
}
Gets called every play.