Skip to content

binaryLoader not being called. #272

Open

Description

@paustian

Issue Details

  • Version used version 1.0.0

  • Describe whats happening (Include any relevant console errors, a Gist is preferred for longer errors):
    Loading of binary files does not work.

  • OS & Browser version (Please be specific) (Ex; Windows 10 Home, Chrome 62.0.3202.94):
    MacOS Mojave, Firefox 87.0

  • Do you know of any workarounds?
    None

Trying to load a binary file fails silently. Here is some example code:

let queue = new createjs.LoadQueue();
queue.on("complete", assets_loaded);
queue.on("fileload", handle_file_load);
queue.loadManifest([
{id: "bach_score", src: "Bach_score.png"},
{id: '1badbar1s', src: "exampleplayer/e1/1badbar1.mid", type: createjs.Types.BINARY}]);

I can easily load the png, but the binary file fails silently.

Activity

  1. paustian commented on Apr 16, 2021

    @paustian
    Author

    So some more information on this. Since, I am trying to load a .mid file, SoundJS tries to do it and fails because .mid files are not supported by the plugins I am loading. I continue to investigate.

  2. paustian commented on Apr 26, 2021

    @paustian
    Author

    I figured out the issue. SoundJS has the .mid extension as part of its set of extensions it says it handles. Line 363 in Sound.js.
    Then it checks to see if it can play the type in WebAudioPlugin. With modern browsers this fails. Thus SoundJS promises to load a type but then refuses to do it if the browser cannot support it. This is understandable behavior since I think the developers of SoundJS are being forward-thinking anticipating that at some point midi will be supported in browsers.
    I got around this by changing two parts of the code. First I did a separate check for the mid extension right after the browser capabilities were checked (line 363). This is a bit of a hack:

    if(ext == "mid"){
        s._capabilities[ext] = true;
    }
    

    I then bipass the typical loader code putting this just above the WebAudio Loader code.

    p._sendComplete = function (event) {
    //new code
    if(this._item.ext == 'mid'){
    	this._handleAudioDecoded(this._rawResult);
    	return;
    }
    //Typical loader code.
    Loader.context.decodeAudioData(this._rawResult,
    		createjs.proxy(this._handleAudioDecoded, this),
    		createjs.proxy(this._sendError, this));
    };
    

    This loads the midi file as a raw binary. From here I can deal with it and load it into Midi.js and get it to play.
    Could it be possible to change the logic of SoundJS a bit?

    1. Claim all sound extensions as is being done now.
    2. If a browser check shows they are not supported by the browser, instead of failing to load, set a flag that lets the client know they must deal with it
    3. Load the file as a binary object if possible.

    Hope this helps.

  3. danzen commented on May 2, 2021

    @danzen
    Contributor

    @paustian - that sounds good. I have not done any work with binary. What is it like? How do you decode it after? Do you know your way around the sound loading enough to suggest this more general solution? Cheers.

  4. paustian commented on Jan 8, 2022

    @paustian
    Author

    I apologize for this being so much later. Once I have the file loaded, I used a combination of midi-parser.js, midiplayer.js, and soundfont-player.js to manipulate and play the files.

    I used all of this in a Zikula Module for my wife's textbook. It's called MelodyMixerModule.

  5. danzen commented on Jul 24, 2023

    @danzen
    Contributor

    And I am back - and apologize for the delay. I keep forgetting to check preloadjs. Okay - if you have a specific solution that we can implement, please let us know what it is or submit a pull request. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions