AudioQueueStart fails when iphone app running in background iOS4.0
Asked Answered
G

3

8

I'm having difficulties starting the AudioQueue when my app is in the background with iOS4.0 The code works fine when the app is active, but fails with -12985 code when running in the background.

        err = AudioQueueStart( queueObject, NULL );


        if( err )
        {
            NSLog(@"AudioQueueStart failed with %d", err);
                = NO;
AudioQueueStop(queueObject, YES);
            return;
        }

For the code above, err is set to -12985

Ginglymus answered 25/6, 2010 at 22:26 Comment(0)
G
2

I've since learned that re-using an audioqueue from the background works just fine. You just can't start new.

Ginglymus answered 30/6, 2010 at 1:47 Comment(2)
how to re-use?? specifically?Popham
what? how? say something more plzSusiesuslik
G
3

Making sure that my AudioSession was active fixed the problem: Previously in code I had set the session to inactive between song changes before starting a new song:

AudioSessionSetActive(false);

Once I removed this AudioQueueStart works just fine from the background.

Ginglymus answered 3/7, 2010 at 20:47 Comment(0)
P
3

From Apple Developer Forums:

The solution is actually simple once you know it, and I really wonder why so many question like your spread in many forums don't get answred

...

You to this ensuring your view becomes First Controller and then calling

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

n viewDidLoad. Once you do this, your Player will no longer return NO!!

Popham answered 13/2, 2012 at 8:15 Comment(1)
yasirmturk, you are my hero! What a great answer. 1000 points. ThanksKat
G
2

I've since learned that re-using an audioqueue from the background works just fine. You just can't start new.

Ginglymus answered 30/6, 2010 at 1:47 Comment(2)
how to re-use?? specifically?Popham
what? how? say something more plzSusiesuslik

© 2022 - 2024 — McMap. All rights reserved.