Title: PhoneGap - Not able to play local sound file
Tags: android;cordova;android-mediaplayer
Question: I am working with PhoneGap with an Android device. 

I am trying to play a local .wav file but am getting some errors. 

I am using the example code from 

```http://docs.phonegap.com/en/1.0.0/phonegap_media_media.md.html

document.addEventListener("deviceready", onDeviceReady, false);

    // PhoneGap is ready
    //
    function onDeviceReady() {
        playAudio("sounds/menu-change.wav");
    }

    // Audio player
    var my_media = null;

    // Play audio
    function playAudio(src) {
        // Create Media object from src
        my_media = new Media(src, onSuccess, onError);

        // Play audio
        my_media.play();
    }


    function onSuccess() {
        console.log("playAudio():Audio Success");
    }

    function onError(error) {
        alert('code: '    + error.code    + '\n' + 
              'message: ' + error.message + '\n');
    }
```

I am getting the following error

```09-29 16:06:49.934: D/CordovaLog(14944): JSCallback Error: Request failed.
09-29 16:06:49.934: D/CordovaLog(14944): file:///android_asset/www/js/cordova-2.0.0.js: Line 3698 : JSCallback Error: Request failed.
09-29 16:06:49.934: I/Web Console(14944): JSCallback Error: Request failed. at file:///android_asset/www/js/cordova-2.0.0.js:3698
09-29 16:06:49.944: D/DroidGap(14944): onMessage(onPageStarted,file:///android_asset/www/settings.html)
09-29 16:06:49.964: I/AudioSystem(14944): getting audio flinger
09-29 16:06:49.974: I/AudioSystem(14944): returning new audio session id
09-29 16:06:50.014: E/MediaPlayer(14944): error (1, -438.238.0885)
09-29 16:06:50.014: W/System.err(14944): java.io.IOException: Prepare failed.: status=0x1
09-29 16:06:50.014: W/System.err(14944):    at android.media.MediaPlayer.prepare(Native Method)
09-29 16:06:50.014: W/System.err(14944):    at org.apache.cordova.AudioPlayer.loadAudioFile(AudioPlayer.java:544)
09-29 16:06:50.014: W/System.err(14944):    at org.apache.cordova.AudioPlayer.readyPlayer(AudioPlayer.java:468)
09-29 16:06:50.014: W/System.err(14944):    at org.apache.cordova.AudioPlayer.startPlaying(AudioPlayer.java:212)
09-29 16:06:50.014: W/System.err(14944):    at org.apache.cordova.AudioHandler.startPlayingAudio(AudioHandler.java:232)
09-29 16:06:50.014: W/System.err(14944):    at org.apache.cordova.AudioHandler.execute(AudioHandler.java:75)
09-29 16:06:50.014: W/System.err(14944):    at org.apache.cordova.api.PluginManager$1.run(PluginManager.java:192)
09-29 16:06:50.014: W/System.err(14944):    at java.lang.Thread.run(Thread.java:1027)

09-29 16:06:50.494: D/CordovaLog(14944): JSCallback: Message from Server: cordova.require('cordova/plugin/Media').onStatus('abf853b7-3e45-f906-fc59-92d9f11e9a14', 1, 0);
09-29 16:06:50.494: D/CordovaLog(14944): file:///android_asset/www/js/cordova-2.0.0.js: Line 3669 : JSCallback: Message from Server: cordova.require('cordova/plugin/Media').onStatus('abf853b7-3e45-f906-fc59-92d9f11e9a14', 1, 0);
09-29 16:06:50.504: I/Web Console(14944): JSCallback: Message from Server: cordova.require('cordova/plugin/Media').onStatus('abf853b7-3e45-f906-fc59-92d9f11e9a14', 1, 0); at file:///android_asset/www/js/cordova-2.0.0.js:3669
09-29 16:06:50.504: D/CordovaLog(14944): JSCallback Error: TypeError: Cannot read property 'statusCallback' of undefined
09-29 16:06:50.504: D/CordovaLog(14944): file:///android_asset/www/js/cordova-2.0.0.js: Line 3670 : JSCallback Error: TypeError: Cannot read property 'statusCallback' of undefined
09-29 16:06:50.504: I/Web Console(14944): JSCallback Error: TypeError: Cannot read property 'statusCallback' of undefined at file:///android_asset/www/js/cordova-2.0.0.js:3670
```

It is saying it requires the media plugin, but I have it enabled in my config.xml file

```<plugin name="Media" value="org.apache.cordova.AudioHandler"/&gt;
```

Any help would be much appreciated. 

Thanks



Here is another answer: When using an sound file located in your www folder you'll need to use the following file path format on Android:

```new Media("/android_asset/www/{directory}/{file-name}.mp3");```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:09/29/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<android><cordova><android-mediaplayer>', 'Title': 'PhoneGap - Not able to play local sound file', 'ViewCount': 1385, 'id': 12657341, 'user_AboutMe': '', 'user_AccountId': 1002519.0, 'user_DisplayName': 'nomaam', 'user_Reputation': 1183.0, 'user_Views': 264.0, 'user_id': 1017063.0}}