Skip to content

Unable to trigger loadHandler with CordovaAudioPlugin #170

Open
@ghost

Description

<script src="cordova.js"></script> <script src="soundjs-0.6.1.combined.js"></script> <script src="cordovaaudioplugin-0.6.1.min.js"></script> <script> createjs.Sound.on("fileload", this.loadHandler, this); createjs.Sound.registerPlugins([createjs.WebAudioPlugin]); createjs.Sound.registerSound("/android_asset/www/test.mp3", "noise");
    function loadHandler(event) {
        document.getElementById("debug").innerHTML = "Loaded";
        var instance = createjs.Sound.play("noise");
    }
</script>

<body>
    <span id='debug'></span>
</body>

The code above works beautifully. If I change WebAudioPlugin to CordovaAudioPlugin, the loadHandler never gets executed and thus I get no sound.

I tried wrapping the whole code around document.addEventListener("deviceready", function(){ }); but I received an error pointing to soundjs-0.6.1.combined.js's

p.on = function(type, listener, scope, once, data, useCapture) {
if (listener.handleEvent) { ...

The problem is that listener is undefined.

  1. Why the code doesn't work with CordovaAudioPlugin?
  2. Do I need to use deviceready on this code?

PS. This is my plugin list:

cordova-plugin-whitelist 1.0.0 "Whitelist"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.file 1.3.3 "File"
org.apache.cordova.media 0.2.16 "Media"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions