Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set several options in the setCategory method of AVAudioSession in Objective-C?

I am trying to use AVAudioSession setCategory method with several options and I have seen online that you can specify an array to the options argument in swift but cannot figure out how to do it in objective-C. Here is the documentation where you can see the difference of the options argument expected in swift vs objective-C:

I have tried with objective-C arrays and it does store the options expected.

Thanks for your help!

like image 238
steph Avatar asked Nov 02 '25 07:11

steph


1 Answers

Category options is bit mask. Here is an example of usage

    AVAudioSession *session = AVAudioSession.sharedInstance;
    NSError *error = nil;
    [session setCategory:AVAudioSessionCategoryPlayAndRecord
                    mode:AVAudioSessionModeVoiceChat
                 options:AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionDuckOthers
                   error:&error];
    if (nil == error)
    {
        // continue here
    }
like image 131
Asperi Avatar answered Nov 03 '25 20:11

Asperi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!