features/playback
pause()
function pause(): void;Pauses the current track.
Returns
void
play()
function play(): void;Plays or resumes the current track.
Returns
void
usePlayback()
function usePlayback(): Playback;Hook that returns the current playback state and updates when it changes.
Returns
The current playback state
getPlayback()
function getPlayback(): Playback;Gets the playback state and error (if any) of the player.
Returns
See
PlaybackState for possible state values
togglePlayback()
function togglePlayback(): void;Toggles playback between play and pause.
Returns
void
onPlaybackChanged
const onPlaybackChanged: NativeUpdatedValue<Playback>;Subscribes to playback state changes.
Param
Called when the playback state changes
Returns
Cleanup function to unsubscribe
Playback
type Playback = object;Properties
state
state: PlaybackState;error?
optional error: PlaybackError;PlaybackState
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. CallAudioBrowser.getError()to get more information on the type of error that occurred. CallAudioBrowser.retry()orAudioBrowser.play()to try to play the item again.'ended': Indicates that playback stopped due to the end of the queue being reached.
usePlayingState()
function usePlayingState(): PlayingState;Hook that returns the current playing state and updates when it changes.
Returns
The current playing state (playing and buffering flags)
getPlayingState()
function getPlayingState(): PlayingState;Gets the playing state (playing and buffering flags).
Returns
onPlayingState
const onPlayingState: NativeUpdatedValue<PlayingState>;Subscribes to playing state changes.
Param
Called when playing or buffering state changes
Returns
Cleanup function to unsubscribe
PlayingState
type PlayingState = object;Properties
playing
playing: boolean;buffering
buffering: boolean;usePlayWhenReady()
function usePlayWhenReady(): boolean;Hook that returns the current playWhenReady state and updates when it changes.
Returns
boolean
The current playWhenReady state
getPlayWhenReady()
function getPlayWhenReady(): boolean;Gets whether the player will play automatically when it is ready to do so.
Returns
boolean
setPlayWhenReady()
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
| Parameter | Type |
|---|---|
playWhenReady | boolean |
Returns
void
onPlayWhenReadyChanged
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
| Property | Type | Description |
|---|---|---|
playWhenReady | boolean | Whether the player will play when ready |
usePolledProgress()
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
updateInterval | number | 1000 | Update interval in milliseconds (default: 1000) |
Returns
The current playback progress
useProgress()
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
The current playback progress
getProgress()
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
onProgressUpdated
const onProgressUpdated: NativeUpdatedValue<PlaybackProgressUpdatedEvent>;Subscribes to playback progress updates.
Param
Called periodically with playback progress updates
Returns
Cleanup function to unsubscribe
Progress
Properties
PlaybackProgressUpdatedEvent
Event data for playback progress updates.
Properties
getRate()
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()
function setRate(rate): void;Sets the playback rate.
Parameters
| Parameter | Type | Description |
|---|---|---|
rate | number | The 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()
function reset(): void;Resets the player stopping the current track and clearing the queue.
Returns
void
retry()
function retry(): void;Retries playing the current item when the playback state is 'error'.
Returns
void
See
seekBy()
function seekBy(offset): void;Seeks by a relative time offset in the current track.
Parameters
| Parameter | Type | Description |
|---|---|---|
offset | number | The time offset to seek by in seconds. |
Returns
void
seekTo()
function seekTo(position): void;Seeks to a specified time position in the current track.
Parameters
| Parameter | Type | Description |
|---|---|---|
position | number | The position to seek to in seconds. |
Returns
void
stop()
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()
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()
function getSystemVolume(): number;Gets the current system volume as a number between 0 and 1.
Returns
number
setSystemVolume()
function setSystemVolume(level): void;Sets the system volume.
Parameters
| Parameter | Type | Description |
|---|---|---|
level | number | The 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
const onSystemVolumeChanged: NativeUpdatedValue<number>;Subscribes to system volume changes.
Param
Called when the system volume changes
Returns
Cleanup function to unsubscribe
getVolume()
function getVolume(): number;Gets the volume of the player as a number between 0 and 1.
Returns
number
setVolume()
function setVolume(level): void;Sets the volume of the player.
Parameters
| Parameter | Type | Description |
|---|---|---|
level | number | The volume as a number between 0 and 1. |
Returns
void