I'm pretty sure it's a bug in Cordova...
Here is how it goes, we start with:
navigator.notification.beep
that will trigger (cordova-1.6.1.js):
beep:function(count) {
(new Media('beep.wav')).play();
}
Creating the Media object will result in:
var Media = function(src, successCallback, errorCallback, statusCallback) {
// successCallback optional
if (successCallback && (typeof successCallback !== "function")) {
console.log("Media Error: successCallback is not a function");
return;
}
// errorCallback optional
if (errorCallback && (typeof errorCallback !== "function")) {
console.log("Media Error: errorCallback is not a function");
return;
}
// statusCallback optional
if (statusCallback && (typeof statusCallback !== "function")) {
console.log("Media Error: statusCallback is not a function");
return;
}
this.id = utils.createUUID();
mediaObjects[this.id] = this;
this.src = src;
this.successCallback = successCallback;
this.errorCallback = errorCallback;
this.statusCallback = statusCallback;
this._duration = -1;
this._position = -1;
exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
};
If you look at Cordova.plist you will see that the plugin name "Media" is mapped to "CDVSound" and in CDVSound there is no method create...
And because there is no method "create" for "Media" we get:
cleanApp[24713:707] ERROR: Method 'create:withDict:' not defined in Plugin 'Media'
cleanApp[24713:707] FAILED pluginJSON = {"className":"Media","methodName":"create","arguments":["INVALID","b6acfbad-1e26-de77-1557-0d7c2f87a00a","beep.wav"]}
So how come we can hear the sound?
good question.. if you look at:
new Media('beep.wav')).play();
You notice that we call play(), let's see what that does:
Media.prototype.play = function(options) {
exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
};
in CDVSound.h:
- (void) startPlayingAudio:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;