I am trying to play midi in a loop. For this I am calling play() inside endOfFile event listener which sounds like a sensible thing to do, but this fails with an error "already playing". I tried calling stop() and then play(), or skipToTick(0) but it has no effect.
The problem is that the library is firing the endOfFile before the internal stop(). I think it should be the other way around, otherwise it makes it impossible to do anything with the Player playback within the event handler, as while I am processing the event in my event handler the library is firing the stop() command next no matter what.
So I think endOfFile trigger should be implemented like this:
if (!dryRun && this.endOfFile()) {
//console.log('end of file')
this.stop();
this.triggerPlayerEvent('endOfFile'); //afer stop()
} else {
Then calling play() inside the endOfFile event handler causes the midi to loop infinitely, as expected.
I am trying to play midi in a loop. For this I am calling
play()
insideendOfFile
event listener which sounds like a sensible thing to do, but this fails with an error "already playing". I tried calling stop() and then play(), or skipToTick(0) but it has no effect.The problem is that the library is firing the endOfFile before the internal stop(). I think it should be the other way around, otherwise it makes it impossible to do anything with the Player playback within the event handler, as while I am processing the event in my event handler the library is firing the stop() command next no matter what.
So I think endOfFile trigger should be implemented like this:
Then calling play() inside the endOfFile event handler causes the midi to loop infinitely, as expected.
Thanks.