In my iOS app, I'm playing youtube videos using YTPlayerView (see this link for information), but video playback pauses if app has entered background. I would like to continue playing videos in background, I added "Audio and AirPlay" to "Required background modes" and set audio session in application delegate this way:
- (void) setAudioSession
{
NSError *setCategoryErr = nil;
NSError *activationErr = nil;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryErr];
if (setCategoryErr)
{
NSLog(@"Setting Audio Session Category Error: %@",[setCategoryErr description]);
}
[audioSession setActive:YES error:&activationErr];
if (activationErr)
{
NSLog(@"Activating Audio Session Error: %@",[activationErr description]);
}
}
but however video pauses when app enters background. What else should I do to make it work?