State & Progress
All state getters are synchronous — they return values immediately, no await needed.
Playback state
Gets the current playback state. Android returns `'idle'` until startup finishes. Do not gate startup writes on this value; see setupPlayer.
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:
Whether the player is currently producing audio output. Android returns `false` until startup finishes. Do not gate startup writes on this value; see setupPlayer.
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
Gets position, duration, buffered position, and cached position in seconds. Android returns zeros until startup finishes. Do not gate startup writes on these values; see setupPlayer.
| 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
Gets the current playback speed. Android returns `1` until startup finishes. Do not gate startup writes on this value; see setupPlayer.
Gets the current player volume (0.0 to 1.0). Android returns `1` until startup finishes. Do not gate startup writes on this value; see setupPlayer.
Repeat and shuffle
Gets the current repeat mode. Android returns `'off'` until startup finishes. Do not gate startup writes on this value; see setupPlayer.
Whether shuffle is enabled. Android returns `false` until startup finishes. Do not gate startup writes on this value; see setupPlayer.
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 none is active.
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.