1

Is it possible to have two or more MIDI.js Player's on a page?

This seems to create and then populate only one MIDI object, regardless of how many elements of class nmidiplayer there are:

$(document).ready(function() {                                                             
    $('.nmidiplayer').each(npMIDIPlayer);
});

function npMIDIPlayer(idx, elem) {
    var midi = MIDI;
    // ....
}

Please, it it possible with MIDI.js? How?

brownian
  • 435
  • 3
  • 13
  • Isn't just about creating another instance of a `Player`? – Nonemoticoner Mar 24 '16 at 14:08
  • @Nonemoticoner, please, how to initialize just another instance? I am not a programmer, I'm trying to solve this in a way I understand now, but no success. Thank you. – brownian Mar 24 '16 at 14:38
  • I believe you need another `MIDI` object. Here's how to achieve it: http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object – Nonemoticoner Mar 24 '16 at 15:33
  • But without understanding JavaScript you will surely face many more problems later anyway. – Nonemoticoner Mar 24 '16 at 15:35
  • @Nonemoticoner, if I was a programmer, I would hardly consider cloning of already existing objects as a proper way of creating new instances (not clones). So, if this is the only possibility for `MIDI.js` --- I do rather not need to have multiple players. – brownian Mar 25 '16 at 07:16
  • `Player` is an object that belongs to `MIDI` object and you could maybe copy only that `Player` to have another "playing machine". Yet, it most probably rely on some other properties belonging to `MIDI` object and so by this `Player` wouldn't work properly. It is only a matter of doubling amount of memory needed for a program. – Nonemoticoner Mar 25 '16 at 13:20

0 Answers0