Skip to main content
Version: v2.1.0

Queue

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Queue()

Defined in

Queue.ts:8

Properties

tracks

tracks: (Track)[]

Defined in

Queue.ts:6

Accessors

duration

get duration(): number

Gets the queue duration in milliseconds.

Returns

number

Defined in

Queue.ts:22


size

get size(): number

Gets the queue size.

Returns

number

Defined in

Queue.ts:15

Methods

add

add(track): void

[Internal] Adds a track to the queue. External users should use Player.addTracks() method instead.

Parameters

NameTypeDescription
trackTrackThe track to add to the queue

Returns

void

Defined in

Queue.ts:30


clear

clear(): void

Clears the queue.

Returns

void

Defined in

Queue.ts:81


insert

insert(index, track): boolean

Inserts a track at the specified index, moving subsequent tracks back.

Parameters

NameTypeDescription
indexnumberThe index at which to insert the track.
trackTrackThe track to insert.

Returns

boolean

Throws

Throws an error if the index is out of range.

Defined in

Queue.ts:40


move

move(index1, index2): boolean

Moves a track from one index to another within the queue.

Parameters

NameTypeDescription
index1numberThe current index of the track.
index2numberThe new index to which the track should be moved.

Returns

boolean

Returns true if the track was successfully moved, false otherwise.

Defined in

Queue.ts:134


poll

poll(): null | Track

Polls the queue for the next track.

Returns

null | Track

The next track in the queue or null if the queue is empty.

Defined in

Queue.ts:53


remove

remove(): boolean

Removes the first track in the queue.

Returns

boolean

Returns true if the track was successfully removed, false otherwise

Defined in

Queue.ts:89

remove(index): boolean

Removes the track at the specified position.

Parameters

NameTypeDescription
indexnumberThe index of the track to remove.

Returns

boolean

Returns true if the track was successfully removed, false otherwise

Defined in

Queue.ts:95

remove(start, end): boolean

Removes the tracks in the specified range.

Parameters

NameTypeDescription
startnumberThe start index of the range.
endnumberThe end index of the range.

Returns

boolean

Returns true if the tracks were successfully removed, false otherwise

Defined in

Queue.ts:102


shuffle

shuffle(): void

Shuffles the queue

Returns

void

Defined in

Queue.ts:68


skipNTracks

skipNTracks(n): void

Remove the next n tracks from the queue

Parameters

NameTypeDescription
nnumberThe number of tracks to skip

Returns

void

Defined in

Queue.ts:61