Skip to content

endOfFile event should fire after stop() #86

@serg472

Description

@serg472

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.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions