瀏覽代碼

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

sschmidTU 3 年之前
父節點
當前提交
d86a24aec7
共有 1 個文件被更改,包括 5 次插入1 次删除
  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();
     }