Cordova Phonegap构建:为什么不播放音频?

Cordova Phonegap构建:为什么不播放音频?,cordova,phonegap-build,Cordova,Phonegap Build,如果我使用phonegap构建,我无法调试,因为开发人员工具没有名为Media的对象。但我已经构建了应用程序,并在设备(安卓4.1.2)上进行了测试,但音频无法播放 在我添加媒体功能后,它已停止工作 以下是代码示例: config.xml <?xml version="1.0" encoding="UTF-8" ?> <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phoneg

如果我使用phonegap构建,我无法调试,因为开发人员工具没有名为
Media
的对象。但我已经构建了应用程序,并在设备(安卓4.1.2)上进行了测试,但音频无法播放

在我添加
媒体
功能后,它已停止工作

以下是代码示例:

config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns   = "http://www.w3.org/ns/widgets"
    xmlns:gap   = "http://phonegap.com/ns/1.0"
    id          = "com.phonegap.audiotest"
    versionCode = "10" 
    version     = "1.0.0" >
<!-- versionCode is optional and Android only -->

<name>Audio Test</name>

<description>
    An example for phonegap Audio. 
</description>

<author href="https://www.whatwgisnottelling.com" email="anyname@gmail.com">
    justTest
</author>

<gap:plugin name="org.apache.cordova.media" version="0.2.8" />

</widget>

媒体文件的路径不正确。必须正确获取路径:

  var getPathMedia = function () {
    var path = window.location.pathname;
    var phoneGapPath = path.substring(0, path.lastIndexOf('/') + 1);
    // Return path at www folder
    return 'file://' + phoneGapPath;
  };
  var media = new Media(getPathMedia() + 'media/message.mp3');

我试过使用和不使用
'文件://'
以及使用和不使用
媒体/message.wav
但都不起作用。有什么想法吗?我不能在Eclipse上模仿,我只是构建应用程序并在我的手机上进行测试。我得到一个错误“1”。
var App = {
    initialize: function () {
        this.touchEvents();
    },
    touchEvents: function () {
        $(document).bind('touchmove', function(e) {
            e.preventDefault();
        });
        var media = new Media();
        var box = document.getElementById('box');
        box.addEventListener('touchstart', function () {
            box.style.backgroundColor = 'black';
            media.play("song.wav");
        });
        box.addEventListener('touchend', function () {
            box.style.backgroundColor = 'red';
            media.stop("song.wav");
        });
       }
};
  var getPathMedia = function () {
    var path = window.location.pathname;
    var phoneGapPath = path.substring(0, path.lastIndexOf('/') + 1);
    // Return path at www folder
    return 'file://' + phoneGapPath;
  };
  var media = new Media(getPathMedia() + 'media/message.mp3');