Playlist
A list of items to play.
Downloaded media doesn't work with playlists on Apple devices. We recommend using the single player configuration for downloaded media.
Constructors
new Playlist(items, onItemChanged, onEnded)
new Playlist(
items,
onItemChanged?,
onEnded?): Playlist
Create a new playlist.
Parameters
Parameter | Type | Description |
---|---|---|
items | PlayerConfiguration [] | The items in the playlist. |
onItemChanged ? | PlaylistItemChangedCallback | The callback to trigger when the item is changed. |
onEnded ? | PlaylistEndedCallback | The callback to trigger when the playlist ends. |
Accessors
current
get current(): undefined | PlayerConfiguration
The current item in the playlist.
currentIndex
get currentIndex(): number
The index of the current item in the playlist.
items
get items(): readonly PlayerConfiguration[]
The items in the playlist.
Methods
hasNext()
hasNext(): boolean
Check if there is a next item in the playlist.
Returns
True if there is a next item, false otherwise.
hasPrev()
hasPrev(): boolean
Check if there is a previous item in the playlist.
Returns
True if there is a previous item, false otherwise.
insert()
insert(playerConfiguration, at?): Promise<void>
Add an item to the playlist.
Parameters
Parameter | Type | Description |
---|---|---|
playerConfiguration | PlayerConfiguration | The player configuration for the item. |
at ? | number | The index to insert the item at. |
Returns
A promise that resolves when the item is added.
playItem()
playItem(at): Promise<void>
Play an item in the playlist.
Parameters
Parameter | Type | Description |
---|---|---|
at | number | The index of the item to play. |
Returns
A promise that resolves when the item is played.
Throws
If the playlist is not ready.
Throws
If the item doesn't exist.
playNext()
playNext(): Promise<void>
Play the next item in the playlist.
Returns
A promise that resolves when the next item is played.
Throws
If the playlist is not ready.
Throws
If the next item doesn't exist.
playPrev()
playPrev(): Promise<void>
Play the previous item in the playlist.
Returns
A promise that resolves when the previous item is played.
Throws
If the playlist is not ready.
Throws
If the previous item doesn't exist.
remove()
remove(at): Promise<void>
Remove an item from the playlist.
Parameters
Parameter | Type | Description |
---|---|---|
at | number | The index of the item to remove. |
Returns
A promise that resolves when the item is removed.
Throws
If the item doesn't exist.