floatinghotpot / cordova-plugin-nativeaudio

The low latency audio plugin is designed to enable low latency and polyphonic audio from Cordova/PhoneGap applications, using a very simple and basic API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to read [command argumentAtIndex:0]

jvwelzen opened this issue · 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];
}