Essentially.... the code which CS creates lacks that /android_assett/www/ part, so it won't find the files (will look on SD card instead).
This article pointed that out:
simonmacdonald.blogspot.com/2011/05/using-media-class-in-phonegap.html
So I did...
1. in the c2runtime.js file I found the new Media() call and made it thus:
case API_PHONEGAP:
this.instanceObject = new Media("/android_asset/www/" + buffer_.src);
break;
2. I also set the default api to be API_PHONEGAP (because on my tests it didn't detect properly)... so:
var API_HTML5 = 0;
var API_WEBAUDIO = 1;
var API_PHONEGAP = 2;
var API_APPMOBI = 3;
var api = API_PHONEGAP;
3. I made the hasEnded() function return true for PhoneGap (as it wasn't working in my trial)...
So...
C2AudioInstance.prototype.hasEnded = function ()
{
switch (this.myapi) {
case API_HTML5:
return this.instanceObject.ended;
case API_WEBAUDIO:
if (!this.fresh && !this.stopped && this.instanceObject["loop"])
return false;
return (audRuntime.kahanTime.sum - this.startTime) > this.buffer.bufferObject["duration"];
case API_PHONEGAP:
return true; //(audRuntime.kahanTime.sum - this.startTime) > this.buffer.bufferObject.getDuration();
case API_APPMOBI:
true; // recycling an AppMobi sound does not matter because it will just do another throwaway playSound
}
4. And in this call, I added the test for phonegap to prevent it doing the usual action:
instanceProto.tick = function ()
{
var i, len, a;
for (i = 0, len = audioInstances.length; i < len; i++)
{
a = audioInstances;
if (a.myapi !== API_HTML5 && a.myapi !== API_APPMOBI
&& a.myapi != API_PHONEGAP)
// PHONEGAP bit added above...
{
if (!a.fresh && !a.stopped && a.hasEnded())
{
a.stopped = true;
audTag = a.tag;
audRuntime.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded, audInst);
}
....I also (I should add) made the audio files be mp3s (for my test) and searched and replaced the references to .ogg and .m4a to be .mp3
This was all done in the NON-minified JS..... and all seems to work fine when built as an Android APK via PhoneGap.
If others (eg. ranma) have already got this working, then that's great, but it wasn't working for me (and perhaps not for others) and this is what it took to fix it. So hopefully that's of help to someone. :-)