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.
MIT License
233 stars 290 forks source link

How to read [command argumentAtIndex:0] #125

Closed jvwelzen closed 7 years ago

jvwelzen commented 7 years ago

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];
}
jvwelzen commented 7 years ago

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];
}