Explorar o código

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

sschmidTU %!s(int64=3) %!d(string=hai) anos
pai
achega
d86a24aec7
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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();
     }