Thursday, June 6, 2013

AVAudioSession AVAudioSessionCategorySoloAmbient example in Objective C (iOS).


AVAudioSession AVAudioSessionCategorySoloAmbient

NSString *const AVAudioSessionCategorySoloAmbient;

The default category; used unless you set a category with the setCategory:error: method.
When you use this category, audio from other apps is silenced. Your audio is silenced by screen locking and by the Silent switch (called the Ring/Silent switch on iPhone).

AVAudioSession AVAudioSessionCategorySoloAmbient example.
if (backgroundSwitch.on) {
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
}else {
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:NULL];
}

Example of [AVAudioSession AVAudioSessionCategorySoloAmbient].
In the initWithCoder method:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:NULL];

End of AVAudioSession AVAudioSessionCategorySoloAmbient example article.