State & Progress

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

Playback state

TrackPlayer.getPlaybackState():PlaybackState

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

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
FieldTypeDefaultDescription
position * numberCurrent playback position in seconds.
duration * numberTotal duration of the media item in seconds.
buffered * numberBuffered position in seconds.
cached * numberCached-on-disk position in seconds. 0 when caching is not enabled.

Speed and volume

TrackPlayer.getPlaybackSpeed():number
TrackPlayer.getVolume():number

Repeat and shuffle

TrackPlayer.getRepeatMode():RepeatMode
TrackPlayer.isShuffleEnabled():boolean

Available repeat modes:

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

Sleep timer

TrackPlayer.getSleepTimer():| { type: 'time'; remainingSeconds: number; fadeOutSeconds: number; } | { type: 'mediaItem'; index: number; } | null

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