I've searched the internet high and low, have tried every recommendation and still no luck. I'm very resourceful and this has completely stumped me. I'm using Phonegap build, then I download to my Android Galaxy S4. I have had it work in Ripple, but even then no luck on the phone. My audio files are located in asset/www/audio/
The consistent error I receive is: Uncaught ReferenceError: Media is not defined I have tried every file structure and still no dice. Including what most answer call for
file:///android_asset/www/audio/horn.mp3
/android_asset/www/audio/horn.mp3
Included in config.xml(in regards to this issue):
<preference name="phonegap-version" value="3.5.0" />
<gap:plugin name="org.apache.cordova.media" version="0.2.13" />
First the call (have multiple places to call different audio files)
<a href="#" data-transition="flip" data-role="button" onClick="audioPathOne();">Start</a>
<a href="#" data-transition="flip" data-role="button" onClick="audioPathTwo();">Start</a>
In my js file...
function audioPathOne () {
playAudio(getPhoneGapPath () + 'audio/beep.mp3');
}
function audioPathTwo() {
playAudio(getPhoneGapPath () + 'audio/horn.mp3');
}
function playAudio() {
my_media = new Media();
my_media.play();
function pauseAudio() {
if (my_media) {
my_media.pause();
}
function stopAudio() {
if (my_media) {
my_media.stop();
}
clearInterval(mediaTimer);
mediaTimer = null;
}
function onSuccess() {
console.log("playAudio():Audio Success");
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
}
function getPhoneGapPath() {
var path = window.location.pathname;
path = path.substr( path, path.length - 10 );
return 'file://' + path;
};