Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:40:07+00:00 2026-06-09T20:40:07+00:00

I’m using the AudioEncode plugin for PhoneGap (Cordova) on iOS. After updating a couple

  • 0

I’m using the AudioEncode plugin for PhoneGap (Cordova) on iOS. After updating a couple of lines for a newer version of Cordova, it appears to be correctly encoding wav files as m4a. In the Xcode console I see:

AVAssetExportSessionStatusCompleted
doing success callback

When I look at the file system on the phone, the wav file has indeed become a m4a. However, the success callback (where I upload the file to a server) is never run. This is the relevant code in the plugin:

-(void) doSuccessCallback:(NSString*)path {
    NSLog(@"doing success callback");
    NSString* jsCallback = [NSString stringWithFormat:@"%@(\"%@\");", self.successCallback, path];
    [self writeJavascript: jsCallback];
    [self.successCallback release];
}

My code in the app goes like this:

function encodeSuccess (path) {
    console.log('Audio encoded to M4A! Preparing to upload...')
    // file transfer code...
}

console.log('Preparing to encode audio file...')
window.plugins.AudioEncode.encodeAudio(entry.fullPath, encodeSuccess, fail)

I’m assuming the doSuccessCallback function in the plugin needs to be updated, but I don’t have experience with Objective C or PhoneGap plugins, so I’m stuck at this point.

Any ideas?

UPDATE

In the Objective C function posted above, I tried logging self.successCallback, and it logged as <null>. Then I went up to the top of the main encodeAudio function, and the argument which is assigned to self.successCallback ([arguments objectAtIndex:1]) also logs as <null>. So, it seems to me that the callbacks are not being passed into the main function successfully.

This is the AudioEncode.h file, maybe someone can spot the problem here:

@interface AudioEncode : CDVPlugin {
    NSString* successCallback;
    NSString* failCallback;
}

@property (nonatomic, retain) NSString* successCallback;
@property (nonatomic, retain) NSString* failCallback;

- (void)encodeAudio:(NSArray*)arguments withDict:(NSDictionary*)options;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:40:09+00:00Added an answer on June 9, 2026 at 8:40 pm

    Ok, I figured this out by reading the basic examples in the Cordova Plugin Development Guide closely. The problem was with the ordering of parameters for cordova.exec(), which must have changed recently.

    I plan to submit a pull request on GitHub with a working version of the plugin, but for now, here’s the basic solution.

    Before asking this question, I had updated the imports in AudioEncode.h from #import <PhoneGap/PGPlugin.h> to:

    #import <Cordova/CDVPlugin.h>
    #import <Cordova/CDVPluginResult.h>
    

    Any reference to PGPlugin should also be updated to CDVPlugin, and PhoneGap should become cordova.

    Here’s the crux of the problem: in AudioEncode.js, cordova.exec() (where the original plugin calls PhoneGap.exec()) needs to be called like this:

    AudioEncode.prototype.encodeAudio = function(audioPath, successCallback, failCallback) {
        cordova.exec(successCallback, failCallback, "AudioEncode", "encodeAudio", [audioPath]);
    };
    

    If you don’t order the parameters like this, the callbacks won’t be passed in (although audioPath was…). Look at the docs for more details, but the parameters have to be the two callbacks first, the module name, the module action, and finally an array of extra parameters.

    Then, you’ll need to read in the parameters in the main encodeAudio function like this:

    self.callback = [[arguments objectAtIndex:0] retain];
    NSString* audioPath = [arguments objectAtIndex:1];
    

    Note that there is only one callback object now, which contains references to the success and fail callbacks. This means that whenever the plugin sets up variables for successCallback and failCallback, you now only need callback (e.g. @synthesize callback). This is also declared in the AudioEncode.h file with @interface and @property.

    Now, when actually firing the callbacks & returning data (in the doSuccessCallback and doFailCallback functions), you need to use CDVPluginResult, like this:

    CDVPluginResult* pluginResult = nil;
    NSString* javaScript = nil;
    
    pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:path];
    javaScript = [pluginResult toSuccessCallbackString:self.callback];
    
    [self writeJavascript: javaScript];
    [self.callback release];
    

    Until I get the updated module up on GitHub, this should help anyone to get the plugin working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.