State & Progress
All state getters are synchronous — they return values immediately, no await needed.
Playback state
Returns a PlaybackState value:
| PlaybackState | Value | Description |
|---|---|---|
| PlaybackState.Idle | 'idle' | — |
| PlaybackState.Ready | 'ready' | — |
| PlaybackState.Buffering | 'buffering' | — |
| PlaybackState.Ended | 'ended' | — |
| PlaybackState.Error | 'error' | — |
Buffering covers both the initial load and any mid-playback rebuffer. Use the helper if you only care about whether audio is currently producing output:
isPlaying() is true only while the player is actively rendering audio — it returns false during buffering, seeking, paused, and ended states. Pair it with getPlaybackState() when you need finer-grained UI (e.g. distinguish “paused” from “buffering”).
Progress
| Field | Type | Default | Description |
|---|---|---|---|
| position * | number | — | Current playback position in seconds. |
| duration * | number | — | Total duration of the media item in seconds. |
| buffered * | number | — | Buffered position in seconds. |
| cached * | number | — | Cached-on-disk position in seconds. 0 when caching is not enabled. |
Speed and volume
Repeat and shuffle
Available repeat modes:
| RepeatMode | Value | Description |
|---|---|---|
| RepeatMode.Off | 'off' | — |
| RepeatMode.One | 'one' | — |
| RepeatMode.All | 'all' | — |
Sleep timer
Returns the current sleep timer state, or null if no timer is active. The shape is a discriminated union on type:
type | Other fields |
|---|---|
'time' | remainingSeconds, fadeOutSeconds |
'mediaItem' | index |
const timer = TrackPlayer.getSleepTimer();
if (timer?.type === 'time') {
console.log(`${Math.ceil(timer.remainingSeconds / 60)} minutes left`);
} Using hooks
For UI components, prefer the hooks — they subscribe to changes and re-render automatically.
See Hooks for usePlaybackState, useIsPlaying, useProgress, and useActiveMediaItem.