kittykatattack / sound.js

A micro-library to load, play and generate sound effects and music for games and interactive applications
304 stars 44 forks source link

looking for a way to use with severals files... and don't mix them at playback #13

Open ajrd2000 opened 7 years ago

ajrd2000 commented 7 years ago

Hello!!

Very good library!! I appreciate too much your work!

That is my question, or my issue better: i need to play several files.. one after other and other .. until the end, I have the name of the files dynamically .. so they are not like fixed names like the example of the included instructions ..

In the instructions included the code is like : //Load the sounds sounds.load([ "sounds/shoot.wav", "sounds/music.wav", "sounds/bounce.mp3" ]);

but I would to load them from a json string. Like this: {"sounds": [{"id": 1,"filename": "demo.mp3"},{"id": 2,"filename": "oly.mp3"}]}

I code the following lines but those works just with one or two files

bs_resultado().each(function (r) { if (r.id > 1) { var filenamesound = "sounds/files/" + r.filename; sounds.load([ filenamesound ]);

        }

});

is available any instructions to avoid one file will be played before the other one has finished ? because when i play them ..

bs_resultado().each(function (r) {
        if (r.id > 1) {
            var filenamesound = "sounds/files/" + r.filename;
            var music = sounds[filenamesound ];
            music.setEcho(echoparam1, echoparam2, 1000);
            music.playbackRate = playbackrate;
            music.play();
        }
    }); 

.. they mix, do not sound one after another

Give me your hand! Regards!

kittykatattack commented 7 years ago

Hello! This library doesn't currently support what you are trying to do - there is no onComplete callback, for example. You might want to try Howler.js: https://howlerjs.com