osmd-audio-player icon indicating copy to clipboard operation
osmd-audio-player copied to clipboard

simple event addition : end of score EVENT

Open patikapusula opened this issue 4 years ago • 1 comments

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");
    }
}

patikapusula avatar Feb 20 '21 13:02 patikapusula

Hi! Thanks, yes this could definitely useful. Feel free to open a PR with the change or I can integrate it myself soon.

jimutt avatar Mar 02 '21 21:03 jimutt