Player src/managers/Player.ts#L29
A manager to perform actions which belongs to the spotify player web api.
Properties:
clientMethods:
addItem getCurrentPlayback getCurrentlyPlaying getDevices getRecentlyPlayed pause play previous seek setRepeatState setShuffleState setVolume skip transferPlaybackconstructor(client) src/managers/Player.ts#L29
No documentation found.
Name | Type | Description |
---|---|---|
client | Client | The spotify api client. |
.addItem(uri, deviceID) src/managers/Player.ts#L248
Add an item to the current user's queue. This method requires a spotify premium account.
await player.addItem('uri');
Returns:
Parameters:
Name | Type | Description |
---|---|---|
uri | string | The uri of the track or the episode to add to the queue. |
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.getCurrentPlayback(additionalTypes) src/managers/Player.ts#L39
Get the current playback of the current user's player.
const currentPlayback = await player.getCurrentPlayback();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
additionalTypes | "track" | "episode" | A comma-separated list of item types that your client supports besides the default track type. Valid types are: track and episode. OPTIONAL |
.getCurrentlyPlaying(additionalTypes) src/managers/Player.ts#L50
Get the current playing content of the current user's player.
const currentPlayback = await player.getCurrentlyPlaying();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
additionalTypes | "track" | "episode" | A comma-separated list of item types that your client supports besides the default track type. Valid types are: track and episode. OPTIONAL |
.getDevices() src/managers/Player.ts#L69
Get the active devices which are logged into the current user's spotify account.
const devices = await player.getDevices();
Returns:
Parameters:
Name | Type | Description |
---|
.getRecentlyPlayed(options) src/managers/Player.ts#L61
Get the recently played data from the current user's player.
const recentlyPlayed = await player.getRecentlyPlayed();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
options | Partial<Cursor> & { limit?: number, } | The before, after and limit query paramaeters. |
.pause(deviceID) src/managers/Player.ts#L133
Pause the current user's playback. This method requires a spotify premium account.
await player.pause();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.play(options) src/managers/Player.ts#L104
Play or resume the current user's playback. This method requires a spotify premium account. This methods uses the [/me/player/play] endpoint which does not has complete documentation.
await player.play();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
options | { contextURI?: string, deviceID?: string, offset?: number, position?: number, uris?: string[], } | The deviceID, contextURI, uris, offset and position parameter. |
.previous(deviceID) src/managers/Player.ts#L161
Skip to the previous track in the current user's playback. This method requires a spotify premium account.
await player.previous();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.seek(position, deviceID) src/managers/Player.ts#L176
Seek to a paticular position in the current user's player. This method requires a spotify premium account.
await player.seek(10000);
Returns:
Parameters:
Name | Type | Description |
---|---|---|
position | number | The position in milliseconds to seek to. Must be a positive number. Passing in a position that is greater than the length of the track will cause the player to start playing the next song. |
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.setRepeatState(state, deviceID) src/managers/Player.ts#L194
Set the repeat mode for the user’s playback. This method requires a spotify premium account.
await player.setRepeatState('off');
Returns:
Parameters:
Name | Type | Description |
---|---|---|
state | "track" | "off" | "context" | State should be track, context or off. **track** will repeat the current track. **context** will repeat the current context. **off** will turn repeat off. |
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.setShuffleState(state, deviceID) src/managers/Player.ts#L212
Toggle shuffle state for the current user's playback. This method requires a spotify premium account.
await player.setShuffleState();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
state | boolean | The shuffle state to set. |
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.setVolume(volume, deviceID) src/managers/Player.ts#L230
Set volume for the current user's player. This method requires a spotify premium account.
await player.setVolume(80);
Returns:
Parameters:
Name | Type | Description |
---|---|---|
volume | number | The volume to set. Must be a value from 0 to 100 inclusive. |
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.skip(deviceID) src/managers/Player.ts#L147
Skip to the next track in the current user's playback. This method requires a spotify premium account.
await player.skip();
Returns:
Parameters:
Name | Type | Description |
---|---|---|
deviceID | string | The id of the device this command is targeting. If not supplied, the user’s currently active device is the target. OPTIONAL |
.transferPlayback(deviceID, play) src/managers/Player.ts#L81
Transfer the playback to an another device. This method requires a spotify premium account.
await player.transferPlayback('deviceID');
Returns:
Parameters:
Name | Type | Description |
---|---|---|
deviceID | string | The device id to be transferred. |
play | boolean | The playback state to set by default it is false. |