Parcourir la source

add PlaybackManager.setPlaybackStart(timestamp) method

sschmidTU il y a 3 ans
Parent
commit
b9c980652b
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9 0
      src/Playback/PlaybackManager.ts

+ 9 - 0
src/Playback/PlaybackManager.ts

@@ -414,6 +414,15 @@ export class PlaybackManager implements IPlaybackParametersListener {
         return this.timingSource.Settings.getDurationAsNoteDuration(timeInMs);
     }
 
+    /** 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().
+     */
+    public setPlaybackStart(timestamp: Fraction): void {
+        this.musicPartManager.MusicSheet.SelectionStart = timestamp;
+        this.reset();
+    }
+
     public Dispose(): void {
         // lock(this.playbackThreadSyncObject) {
             this.listeners = [];