2

I am trying to play a wav file from my PG application and it works properly on the iPhone.

I have read all the following: audio not working with phoneGap How to play song in Android - phonegap Playing local sound in phonegap

I am using PGB to compile my app and its using PG 1.7.0.

I just can figure out how to make it play :(

I tried using

function getPhoneGapPath() {
    var path = window.location.pathname;
    path = path.substr( path, path.length - 10 );
    return 'file://' + path;
};

var pathToCheerFile=getPhoneGapPath()+ 'sounds/cheer.wav';
console.log('pathToCheerFile=',pathToCheerFile);

return new Media(pathToCheerFile,
        // success callback
        function() {
            console.log("cheer Audio loaded Success");
        },
        // error callback
        function(err) {
            console.log("cheer Audio load Error: " , err);
        },
);

The console is showing pathToCheerFile=file:///android_asset/www/sounds/cheer.wav and later it shows cheer Audio load Error: with err being an object that has a single property code:1.

any ideas on what am I doing wrong ?

Community
  • 1
  • 1
epeleg
  • 10,347
  • 17
  • 101
  • 151
  • I am also asking for `` in my config.xml although I am not sure this is needed at all... (is it?) – epeleg Jul 08 '12 at 13:37

1 Answers1

3

Remove the "file://" from your path and it should play just fine.

Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74