Skip to content

features/playback

pause()

ts
function pause(): void;

Pauses the current track.

Returns

void


play()

ts
function play(): void;

Plays or resumes the current track.

Returns

void


usePlayback()

ts
function usePlayback(): Playback;

Hook that returns the current playback state and updates when it changes.

Returns

Playback

The current playback state


getPlayback()

ts
function getPlayback(): Playback;

Gets the playback state and error (if any) of the player.

Returns

Playback

See

PlaybackState for possible state values


togglePlayback()

ts
function togglePlayback(): void;

Toggles playback between play and pause.

Returns

void


onPlaybackChanged

ts
const onPlaybackChanged: NativeUpdatedValue<Playback>;

Subscribes to playback state changes.

Param

Called when the playback state changes

Returns

Cleanup function to unsubscribe


Playback

ts
type Playback = object;

Properties

state

ts
state: PlaybackState;

error?

ts
optional error: PlaybackError;

PlaybackState

ts
type PlaybackState = 
  | "none"
  | "ready"
  | "playing"
  | "paused"
  | "stopped"
  | "loading"
  | "buffering"
  | "error"
  | "ended";

PlaybackState options:

  • 'none': Indicates that the player is idle (initial state, or no track loaded)
  • 'ready': Indicates that the player has loaded a track and is ready to play (but paused)
  • 'playing': Indicates that the player is currently playing
  • 'paused': Indicates that the player is currently paused
  • 'stopped': Indicates that the player is currently stopped
  • 'loading': Indicates that the initial load of the item is occurring.
  • 'buffering': Indicates that the player is currently loading more data before it can continue playing or is ready to start playing.
  • 'error': Indicates that playback of the current item failed. Call AudioBrowser.getError() to get more information on the type of error that occurred. Call AudioBrowser.retry() or AudioBrowser.play() to try to play the item again.
  • 'ended': Indicates that playback stopped due to the end of the queue being reached.

usePlayingState()

ts
function usePlayingState(): PlayingState;

Hook that returns the current playing state and updates when it changes.

Returns

PlayingState

The current playing state (playing and buffering flags)


getPlayingState()

ts
function getPlayingState(): PlayingState;

Gets the playing state (playing and buffering flags).

Returns

PlayingState


onPlayingState

ts
const onPlayingState: NativeUpdatedValue<PlayingState>;

Subscribes to playing state changes.

Param

Called when playing or buffering state changes

Returns

Cleanup function to unsubscribe


PlayingState

ts
type PlayingState = object;

Properties

playing

ts
playing: boolean;

buffering

ts
buffering: boolean;

usePlayWhenReady()

ts
function usePlayWhenReady(): boolean;

Hook that returns the current playWhenReady state and updates when it changes.

Returns

boolean

The current playWhenReady state


getPlayWhenReady()

ts
function getPlayWhenReady(): boolean;

Gets whether the player will play automatically when it is ready to do so.

Returns

boolean


setPlayWhenReady()

ts
function setPlayWhenReady(playWhenReady): void;

Sets whether the player will play automatically when it is ready to do so. This is the equivalent of calling play() when playWhenReady = true or pause() when playWhenReady = false.

Parameters

ParameterType
playWhenReadyboolean

Returns

void


onPlayWhenReadyChanged

ts
const onPlayWhenReadyChanged: NativeUpdatedValue<PlaybackPlayWhenReadyChangedEvent>;

Subscribes to play when ready changes.

Param

Called when playWhenReady changes

Returns

Cleanup function to unsubscribe


PlaybackPlayWhenReadyChangedEvent

Event data for when playWhenReady changes.

Properties

PropertyTypeDescription
playWhenReadybooleanWhether the player will play when ready

usePolledProgress()

ts
function usePolledProgress(updateInterval): Progress;

Hook that returns the current playback progress and updates via polling.

Use this when you need custom polling behavior instead of event-based updates.

Parameters

ParameterTypeDefault valueDescription
updateIntervalnumber1000Update interval in milliseconds (default: 1000)

Returns

Progress

The current playback progress


useProgress()

ts
function useProgress(): Progress;

Hook that returns the current playback progress and updates when it changes.

Progress update frequency is controlled globally via updateOptions({ progressUpdateEventInterval }).

Returns

Progress

The current playback progress


getProgress()

ts
function getProgress(): Progress;

Gets information on the progress of the currently active track, including its current playback position in seconds, buffered position in seconds and duration in seconds.

Returns

Progress


onProgressUpdated

ts
const onProgressUpdated: NativeUpdatedValue<PlaybackProgressUpdatedEvent>;

Subscribes to playback progress updates.

Param

Called periodically with playback progress updates

Returns

Cleanup function to unsubscribe


Progress

Properties

PropertyTypeDescription
positionnumberThe playback position of the current track in seconds.
durationnumberThe duration of the current track in seconds.
bufferednumberThe buffered position of the current track in seconds.

PlaybackProgressUpdatedEvent

Event data for playback progress updates.

Properties

PropertyTypeDescription
positionnumberThe playback position of the current track in seconds.
durationnumberThe duration of the current track in seconds.
bufferednumberThe buffered position of the current track in seconds.
tracknumberThe current track index

getRate()

ts
function getRate(): number;

Gets the playback rate where 0.5 would be half speed, 1 would be regular speed and 2 would be double speed etc.

Returns

number


setRate()

ts
function setRate(rate): void;

Sets the playback rate.

Parameters

ParameterTypeDescription
ratenumberThe playback rate to change to, where 0.5 would be half speed, 1 would be regular speed, 2 would be double speed etc.

Returns

void


reset()

ts
function reset(): void;

Resets the player stopping the current track and clearing the queue.

Returns

void


retry()

ts
function retry(): void;

Retries playing the current item when the playback state is 'error'.

Returns

void

See


seekBy()

ts
function seekBy(offset): void;

Seeks by a relative time offset in the current track.

Parameters

ParameterTypeDescription
offsetnumberThe time offset to seek by in seconds.

Returns

void


seekTo()

ts
function seekTo(position): void;

Seeks to a specified time position in the current track.

Parameters

ParameterTypeDescription
positionnumberThe position to seek to in seconds.

Returns

void


stop()

ts
function stop(): void;

Stops playback and resets position to the beginning. The track remains loaded and can be resumed with play(). For live streams, position is not reset.

Returns

void


useSystemVolume()

ts
function useSystemVolume(): number;

Hook that returns the current system volume and updates when it changes.

Returns

number

The current system volume (0 to 1)


getSystemVolume()

ts
function getSystemVolume(): number;

Gets the current system volume as a number between 0 and 1.

Returns

number


setSystemVolume()

ts
function setSystemVolume(level): void;

Sets the system volume.

Parameters

ParameterTypeDescription
levelnumberThe volume as a number between 0 and 1.

Returns

void

Note

On iOS this is a no-op as Apple doesn't provide a public API to set system volume.


onSystemVolumeChanged

ts
const onSystemVolumeChanged: NativeUpdatedValue<number>;

Subscribes to system volume changes.

Param

Called when the system volume changes

Returns

Cleanup function to unsubscribe


getVolume()

ts
function getVolume(): number;

Gets the volume of the player as a number between 0 and 1.

Returns

number


setVolume()

ts
function setVolume(level): void;

Sets the volume of the player.

Parameters

ParameterTypeDescription
levelnumberThe volume as a number between 0 and 1.

Returns

void