I have the following situation:
- I have phonegap project.
- I build it using "cordova build browser" and then run via "cordova run browser".
The piece of code does not work because it seems that filename.mp3 does not exist in sounds/ dir which is in root dir (i.e. 'www' dir):
path = 'sounds/filename.mp3'; if (OS === "Android") { path = '/android_asset/www/' + path; } else { // } //Open music file var mediaFile = new Media(path, function() { console.log("Playing"); }, function(error) { console.log("Error:" + JSON.stringify(err)); }, function(st) { if (st === Media.MEDIA_STOPPED && exit === !true) { //console.log("audio status changed"); mediaFile.play(); }} ); mediaFile.play();
It does work on Android platform but on desktop log contains interesting thing:
200 /js/lib/scorebar.js (/home/raian/my_project/platforms/browser/www/js/lib/scorebar.js) - as one can see we have both the link and the true path to the file (the same is true for many other resources like images or CSS files...);
404 /sounds/filename.mp3 - here the true path is missing?
Question: is that possible to somehow add/include path to true mp3 file? It looks like mp3 file just has not been copied to sounds/ directory that may easily be somewhere in the filesystem and it is directly depends on how cordova run its server.