Browse Source

setPlaybackStart(): set to start of sheet if called without timestamp argument

sschmidTU 3 years ago
parent
commit
d86a24aec7
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/Playback/PlaybackManager.ts

+ 5 - 1
src/Playback/PlaybackManager.ts

@@ -417,8 +417,12 @@ export class PlaybackManager implements IPlaybackParametersListener {
     /** Sets the cursor and MusicSheet.SelectionStart to the target timestamp (fraction),
      *  but does not start playback if it was not started already.
      *  To get the timestamp from milliseconds, use getTimestampFromMs().
+     *  To reset the playback start to the beginning of the sheet, call the function without arguments.
      */
-    public setPlaybackStart(timestamp: Fraction): void {
+    public setPlaybackStart(timestamp?: Fraction): void {
+        if (!timestamp) {
+            timestamp = this.musicPartManager.MusicSheet.SourceMeasures[0].AbsoluteTimestamp; // start of sheet
+        }
         this.musicPartManager.MusicSheet.SelectionStart = timestamp;
         this.reset();
     }