Home > @unseenco/backstage-core > ISequence > play
ISequence.play() method
Starts playback of a sequence. Returns a promise that either resolves to true when the playback completes, or resolves to false if playback gets interrupted (for example by calling sequence.pause())
Signature:
typescript
play(conf?: {
iterationCount?: number;
range?: IPlaybackRange;
rate?: number;
direction?: IPlaybackDirection;
rafDriver?: IRafDriver;
}): Promise<boolean>;Parameters
| Parameter | Type | Description |
|---|---|---|
| conf | { iterationCount?: number; range?: IPlaybackRange; rate?: number; direction?: IPlaybackDirection; rafDriver?: IRafDriver; } |
Returns:
Promise<boolean>
A promise that resolves when the playback is finished, or rejects if interruped
Example
Usage:
ts
// plays the sequence from the current position to sequence.length
sheet.sequence.play()
// plays the sequence at 2.4x speed
sheet.sequence.play({rate: 2.4})
// plays the sequence from second 1 to 4
sheet.sequence.play({range: [1, 4]})
// plays the sequence 4 times
sheet.sequence.play({iterationCount: 4})
// plays the sequence in reverse
sheet.sequence.play({direction: 'reverse'})
// plays the sequence back and forth forever (until interrupted)
sheet.sequence.play({iterationCount: Infinity, direction: 'alternateReverse})
// plays the sequence and logs "done" once playback is finished
sheet.sequence.play().then(() => console.log('done'))