AudioStreamer icon indicating copy to clipboard operation
AudioStreamer copied to clipboard

Backgroundaudio not working in iOS7

Open JoergHamburg opened this issue 11 years ago • 3 comments

AudioSessionInitialize ( NULL, // 'NULL' to use the default (main) run loop NULL, // 'NULL' to use the default run loop mode ASAudioSessionInterruptionListener, // a reference to your interruption callback self // data to pass to your interruption listener callback ); UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback; AudioSessionSetProperty ( kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory ); AudioSessionSetActive(true);

Functions are deprecated in iOS7. I tried to use AVAudioSession *audioSession = [AVAudioSession sharedInstance]; BOOL ok; NSError *setCategoryError = nil; ok = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioSessionDidChangeInterruptionType:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];

ok = [audioSession setActive:YES error:&setCategoryError];

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; [appDelegate becomeFirstResponder];

but the audio still does not play when going to lock screen. Any advice on this?

Thanks in advanced, Jörg

JoergHamburg avatar Feb 19 '14 10:02 JoergHamburg

I'm also having this issue, anybody managed to have a look at it?

dusker avatar Feb 23 '14 13:02 dusker

I noticed in the sample app the background audio capability isn't checked by default. Enabling this allowed the audio to play in the background as expected

I'd be really interested if someone has converted this to run on ios7 code successfully

Thanks

ashleyevans avatar May 12 '14 20:05 ashleyevans

ashleyevans, I was able to get this to work on ios 8.1.3 if that is any help

frakman1 avatar Jun 10 '15 15:06 frakman1