I am currently working with a cordova plugin which uses the AudioStreamer framework to control and stream audio. I am looking to intercept callbacks sent from the js portion of the plugin in the main javascript code in my application, for example 'pause_success'. When a calls the pause method of the plugin this:
[Error] TypeError: 'undefined' is not a function (evaluating 'window.plugins.stream.pause_success()')
global code (index.html, line 1)
i have tried:
window.plugins.stream.pause_success = function(success){
if(success){
alert('success');
}
};
which does nothing
and:
window.plugins.stream.pause_success(function (){
if(success){
alert('success');
}
});
Which results in the following error
[Error] RangeError: Maximum call stack size exceeded.
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
pause_success (StreamManager.js, line 60)
etc etc
The code for the success callback on the plugin side is as follows:
StreamManager.prototype.pause_success = function(){
if(this.pause_success){
this.pause_success();
}
}
with the actual pause function as follows:
StreamManager.prototype.pause = function(options, success, fail){
this.pause_success = success;
this.pause_error = fail;
cordova.exec(null, null, "Stream", "pause", [options]);
}
Does anyone know the correct way to intercept these callbacks or is it just something done improperly on the plugin side?
The plugin repository can be found here: https://github.com/feedhenry/fh-cordova-plugin-stream
Thanks for your time.