floatinghotpot/cordova-plugin-nativeaudio

How to read [command argumentAtIndex:0]

jvwelzen opened this issue · 1 comments

Can someone help me with this

I am trying to change this plugin but this is the first time

this is something I want to do

- (void) setCategory:(CDVInvokedUrlCommand *)command {
        
    if([command argumentAtIndex:0] == 'duckOthers'){
        
        [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionDuckOthers error:nil];
        
    }

    [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
}

of course I can make multiple functions but This sould can more neat

- (void) setCategoryDuckOthers:(CDVInvokedUrlCommand *)command {
        
    //if([command argumentAtIndex:0] == 'duckOthers'){
        
        [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionDuckOthers error:nil];
        
    //}

    [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
}

- (void) setCategoryMixWithOthers:(CDVInvokedUrlCommand *)command {
        
    //if([command argumentAtIndex:0] == 'duckOthers'){
        
        [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
        
    //}

    [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
}