Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endOfFile event should fire after stop() #86

Open
serg472 opened this issue Jul 12, 2022 · 0 comments
Open

endOfFile event should fire after stop() #86

serg472 opened this issue Jul 12, 2022 · 0 comments

Comments

@serg472
Copy link

serg472 commented Jul 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant