Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backgroundaudio not working in iOS7 #85

Open
JoergHamburg opened this issue Feb 19, 2014 · 3 comments
Open

Backgroundaudio not working in iOS7 #85

JoergHamburg opened this issue Feb 19, 2014 · 3 comments

Comments

@JoergHamburg
Copy link

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

@dusker
Copy link

dusker commented Feb 23, 2014

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

@ashleyevans
Copy link

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

@frakman1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants