State & Progress

All state getters are synchronous — they return values immediately without await.

Playback state

const state = TrackPlayer.getPlaybackState();

Returns a PlaybackState value:

StateDescription
PlaybackState.NonePlayer not initialized
PlaybackState.LoadingBuffering / preparing
PlaybackState.ReadyReady to play
PlaybackState.PlayingCurrently playing
PlaybackState.PausedPaused
PlaybackState.StoppedStopped
PlaybackState.ErrorPlayback error
PlaybackState.EndedQueue finished
const playing = TrackPlayer.isPlaying(); // boolean shorthand

Progress

const { position, duration, buffered, cached } = TrackPlayer.getProgress();
FieldDescription
positionCurrent position in seconds
durationTotal duration in seconds
bufferedHow far ahead is buffered (seconds)
cachedHow much is locally cached (seconds, 0 if caching disabled)

Speed and volume

const speed = TrackPlayer.getPlaybackSpeed(); // number
const volume = TrackPlayer.getVolume();       // 0.0 – 1.0

Repeat and shuffle

const mode = TrackPlayer.getRepeatMode();       // RepeatMode
const shuffle = TrackPlayer.isShuffleEnabled(); // boolean

Sleep timer

const timer = TrackPlayer.getSleepTimer();

Returns the current sleep timer state, or null if no timer is active.

TypeFields
'time'remainingSeconds, fadeOutSeconds
'mediaItem'index
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