State & Progress

All state getters are synchronous — they return values immediately, no await needed.

Playback state

TrackPlayer.getPlaybackState():PlaybackState

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:

PlaybackStateValueDescription
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:

TrackPlayer.isPlaying():boolean

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

TrackPlayer.getProgress():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.

FieldTypeDefaultDescription
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

TrackPlayer.getPlaybackSpeed():number

Gets the current playback speed. Android returns `1` until startup finishes. Do not gate startup writes on this value; see setupPlayer.

TrackPlayer.getVolume():number

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

TrackPlayer.getRepeatMode():RepeatMode

Gets the current repeat mode. Android returns `'off'` until startup finishes. Do not gate startup writes on this value; see setupPlayer.

TrackPlayer.isShuffleEnabled():boolean

Whether shuffle is enabled. Android returns `false` until startup finishes. Do not gate startup writes on this value; see setupPlayer.

Available repeat modes:

RepeatModeValueDescription
RepeatMode.Off 'off'—
RepeatMode.One 'one'—
RepeatMode.All 'all'—

Sleep timer

TrackPlayer.getSleepTimer():SleepTimerState

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:

typeOther 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.

ende