features/queue
useActiveTrack()
function useActiveTrack(): Track | undefined;Hook that returns the current active track and updates when it changes.
Returns
Track | undefined
The current active track or undefined
getActiveTrack()
function getActiveTrack(): Track | undefined;Gets the active track or undefined if there is no current track.
Returns
Track | undefined
onActiveTrackChanged
const onActiveTrackChanged: NativeUpdatedValue<PlaybackActiveTrackChangedEvent>;Subscribes to active track change events.
Param
Called when the active track changes
Returns
Cleanup function to unsubscribe
PlaybackActiveTrackChangedEvent
Event data for when the active track changes.
Properties
| Property | Type | Description |
|---|---|---|
lastIndex? | number | The index of previously active track. |
lastTrack? | Track | The previously active track or undefined when there wasn't a previously active track. |
lastPosition | number | The position of the previously active track in seconds. |
index? | number | The newly active track index or undefined if there is no longer an active track. |
track? | Track | The newly active track or undefined if there is no longer an active track. |
getActiveTrackIndex()
function getActiveTrackIndex(): number | undefined;Gets the index of the active track in the queue or undefined if there is no current track.
Returns
number | undefined
add()
Call Signature
function add(tracks, insertBeforeIndex?): void;Adds one or more tracks to the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
tracks | Track[] | The tracks to add to the queue. |
insertBeforeIndex? | number | (Optional) The index to insert the tracks before. By default the tracks will be added to the end of the queue. |
Returns
void
Call Signature
function add(track, insertBeforeIndex?): void;Adds a track to the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
track | Track | The track to add to the queue. |
insertBeforeIndex? | number | (Optional) The index to insert the track before. By default the track will be added to the end of the queue. |
Returns
void
load()
function load(track): void;Replaces the current track or loads the track as the first in the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
track | Track | The track to load. |
Returns
void
move()
function move(fromIndex, toIndex): void;Move a track within the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
fromIndex | number | The index of the track to be moved. |
toIndex | number | The index to move the track to. If the index is larger than the size of the queue, then the track is moved to the end of the queue. |
Returns
void
useQueue()
function useQueue(): Track[];Hook that returns the current queue and updates when it changes.
Returns
Track[]
The current queue
getQueue()
function getQueue(): Track[];Gets the whole queue.
Returns
Track[]
setQueue()
function setQueue(tracks): void;Sets the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
tracks | Track[] | The tracks to set as the queue. |
Returns
void
onQueueEnded
const onQueueEnded: NativeUpdatedValue<PlaybackQueueEndedEvent>;Subscribes to playback queue ended events.
Param
Called when playback has paused due to reaching the end of the queue
Returns
Cleanup function to unsubscribe
onQueueChanged
const onQueueChanged: NativeUpdatedValue<Track[]>;Subscribes to queue change events. Called when tracks are added, removed, reordered, or when track metadata changes.
Param
Called with the updated queue
Returns
Cleanup function to unsubscribe
PlaybackQueueEndedEvent
Event data for when the playback queue has ended.
Properties
| Property | Type | Description |
|---|---|---|
track | number | The index of the active track when the playback queue ended. |
position | number | The playback position in seconds of the active track when the playback queue ended. |
remove()
Call Signature
function remove(indexes): void;Removes multiple tracks from the queue by their indexes.
If the current track is removed, the next track will activated. If the current track was the last track in the queue, the first track will be activated.
Parameters
| Parameter | Type | Description |
|---|---|---|
indexes | number[] | The indexes of the tracks to be removed. |
Returns
void
Call Signature
function remove(index): void;Removes a track from the queue by its index.
If the current track is removed, the next track will activated. If the current track was the last track in the queue, the first track will be activated.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | number | The index of the track to be removed. |
Returns
void
removeUpcomingTracks()
function removeUpcomingTracks(): void;Clears any upcoming tracks from the queue.
Returns
void
useRepeatMode()
function useRepeatMode(): RepeatMode;Hook that returns the current repeat mode and updates when it changes.
Returns
The current repeat mode
getRepeatMode()
function getRepeatMode(): RepeatMode;Gets the current repeat mode.
Returns
setRepeatMode()
function setRepeatMode(repeatMode): void;Sets the repeat mode.
Parameters
| Parameter | Type | Description |
|---|---|---|
repeatMode | RepeatMode | The repeat mode to set |
Returns
void
onRepeatModeChanged
const onRepeatModeChanged: NativeUpdatedValue<RepeatModeChangedEvent>;Subscribes to repeat mode changes.
Param
Called when repeat mode changes
Returns
Cleanup function to unsubscribe
RepeatMode
type RepeatMode = "off" | "track" | "queue";RepeatMode options:
'off': Playback stops when the last track in the queue has finished playing.'track': Repeats the current track infinitely during ongoing playback.'queue': Repeats the entire queue infinitely.
RepeatModeChangedEvent
Properties
| Property | Type | Description |
|---|---|---|
repeatMode | RepeatMode | The new repeat mode |
useShuffle()
function useShuffle(): boolean;Hook that returns whether shuffle mode is enabled and updates when it changes.
Returns
boolean
Whether shuffle mode is enabled
getShuffle()
function getShuffle(): boolean;Gets whether shuffle mode is enabled.
Returns
boolean
setShuffle()
function setShuffle(enabled): void;Sets whether shuffle mode is enabled. When enabled, tracks play in a randomized order.
Parameters
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | Whether to enable shuffle mode |
Returns
void
toggleShuffle()
function toggleShuffle(): void;Toggles shuffle mode on/off.
Returns
void
onShuffleChanged
const onShuffleChanged: NativeUpdatedValue<boolean>;Subscribes to shuffle mode changes.
Param
Called when shuffle mode changes
Returns
Cleanup function to unsubscribe
skip()
function skip(index, initialPosition?): void;Skips to a track in the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | number | The index of the track to skip to. |
initialPosition? | number | (Optional) The initial position to seek to in seconds. |
Returns
void
skipToNext()
function skipToNext(initialPosition?): void;Skips to the next track in the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
initialPosition? | number | (Optional) The initial position to seek to in seconds. |
Returns
void
skipToPrevious()
function skipToPrevious(initialPosition?): void;Skips to the previous track in the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
initialPosition? | number | (Optional) The initial position to seek to in seconds. |
Returns
void
getTrack()
function getTrack(index): Track | undefined;Gets a track object from the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | number | The index of the track. |
Returns
Track | undefined
The track object or undefined if there isn't a track object at that index.