RT33
RT33

Reputation: 103

How to mute AVAudioPlayer if music from another app is playing in spritekit

By default, I notice that in Spritekit, if audio from another app is playing, it is automatically turned off and the audio in the app plays. How do I make it so that the opposite occurs? How do I make it so that the audio and music and sound effects in the app remain mute and external music plays?

Upvotes: 0

Views: 167

Answers (1)

TwoStraws
TwoStraws

Reputation: 13127

You can use AVAudioSession to adjust the mixing settings. There are few possible audio categories you can choose, but I think AVAudioSessionCategoryAmbient is probably closest to what you want:

NSError *err;
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryAmbient error:&err];

if (err) {
    NSLog(@"There was a problem setting the session category: %@", error);
}

Upvotes: 3

Related Questions