Snapshots
Snapshots are immutable read-model projections shared by Legato runtimes and consumers.
PlaybackSnapshot
Section titled “PlaybackSnapshot”interface PlaybackSnapshot { state: PlaybackState; currentTrack: Track | null; currentIndex: number | null; position: number; duration: number | null; bufferedPosition?: number | null; queue: QueueSnapshot;}Observable semantics from the contract:
durationis nullable.nullmeans unknown or live-like timeline semantics.- A finite
durationvalue is evidence of finite media length, not a seekability guarantee by itself. currentTrackandcurrentIndexcan both benullwhen no active item exists.bufferedPositionis optional and may benull.
Minimal example
Section titled “Minimal example”import type { PlaybackSnapshot } from '@ddgutierrezc/legato-contract';
const snapshot: PlaybackSnapshot = { state: 'ready', currentTrack: null, currentIndex: null, position: 0, duration: null, queue: { items: [], currentIndex: null, },};QueueSnapshot
Section titled “QueueSnapshot”interface QueueSnapshot { items: Track[]; currentIndex: number | null;}Observable semantics from the contract:
itemspreserves queue order.currentIndexis nullable when no active item exists.
Minimal example
Section titled “Minimal example”import type { QueueSnapshot } from '@ddgutierrezc/legato-contract';
const queue: QueueSnapshot = { items: [], currentIndex: null,};