phonegap: Uncaught ReferenceError: Media is not defined
cordova
Solution
Update: The solution was that loading both phonegap.js and cordova.js in the index.html apparently caused a conflict. Removing phonegap.js and leaving cordova.js did the trick.
Problem
I'm trying to play sounds in my phonegap application. The function I use to do so looks as follows: ``` function playAudio(src) { src = "media/sounds/" + src; //go to sound folder always if (device.platform == 'Android') { src = '/android_asset/www/' + src; // Android needs the search path explicitly specified } var mediaRes = new Media(src, function onSuccess() { mediaRes.release(); // release the media resource once finished playing }, function onError(e){ alert("error playing sound: " + JSON.stringify(e) + "\n src: " + src); }); mediaRes.play(); // the actual playing } ``` The strange thing is, if I set up an app which only consists of the index.html file that has javascript in its body part, the sound works. However, it does not work when I use the menu a colleague coded. In that case, I get ``` Uncaught ReferenceError: Media is not defined ``` To switch between the two setups (the simple, working one and the menu one), I just exchange the "www" folder that contains the files. Thus, cordova-plugin-media is available for both in the same manner. For the not-working one, cordova.js and phonegap.js are definitely available (I included a custom alert function in those files to check). Additionally, the sound playing is executed after "deviceready" has been fired. Does anyone have suggestions where to continue debugging? Completely redesigning the menu would probably work, but I want to avoid that if possible in any way.