grimmdude / MidiPlayerJS

♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
https://grimmdude.com/MidiPlayerJS/
MIT License
357 stars 52 forks source link

playing event fires after endOfFile #73

Open simonwiles opened 3 years ago

simonwiles commented 3 years ago
Player.on('playing', (currentTick) => console.log("playing"));
Player.on('endOfFile', () => console.log("endOfFile"));

I consistently get one playing event firing after the endOfFile event. Is this expected behaviour? Thanks!

PetitDevil commented 2 years ago

Same question.

serg472 commented 2 years ago

A fix for this would be to change the implementation from:

if (!dryRun) this.triggerPlayerEvent('playing', {
  tick: this.tick
});

to:

if (!dryRun && this.isPlaying()) this.triggerPlayerEvent('playing', {
  tick: this.tick
});