State & Progress
All state getters are synchronous — they return values immediately without await.
Playback state
const state = TrackPlayer.getPlaybackState(); Returns a PlaybackState value:
| State | Description |
|---|---|
PlaybackState.None | Player not initialized |
PlaybackState.Loading | Buffering / preparing |
PlaybackState.Ready | Ready to play |
PlaybackState.Playing | Currently playing |
PlaybackState.Paused | Paused |
PlaybackState.Stopped | Stopped |
PlaybackState.Error | Playback error |
PlaybackState.Ended | Queue finished |
const playing = TrackPlayer.isPlaying(); // boolean shorthand Progress
const { position, duration, buffered, cached } = TrackPlayer.getProgress(); | Field | Description |
|---|---|
position | Current position in seconds |
duration | Total duration in seconds |
buffered | How far ahead is buffered (seconds) |
cached | How 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.
| Type | Fields |
|---|---|
'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.