osmd-audio-player
osmd-audio-player copied to clipboard
simple event addition : end of score EVENT
An "end of score" callback, useful for adapting the UI elements.
PlaybackEngine.ts
export enum PlaybackEvent {
STATE_CHANGE = "state-change",
ITERATION = "iteration",
END_OF_SCORE = "end-of-score", // new event
}
// callback
private endOfScoreCallback(message: string) {
this.events.emit(PlaybackEvent.END_OF_SCORE, message);
}
// check for "end of score" and firing cb
private iterationCallback() {
if (this.state !== PlaybackState.PLAYING) return;
if (this.currentIterationStep > 0) this.cursor.next();
++this.currentIterationStep;
// Checking here
if (this.currentIterationStep > this.iterationSteps) {
this.endOfScoreCallback("End of score");
}
}
Hi! Thanks, yes this could definitely useful. Feel free to open a PR with the change or I can integrate it myself soon.