spotify-application-client
v1.0.5
Published
A client for the Spotify application on MacOS
Downloads
25
Readme
Spotify Application Client for MacOS
Node Client for the Spotify App on Mac OS
Overview
Spotify built an AppleScript API that enables programmatic control of the player (on Mac OS).
This client sits on top of this AppleScript API to provide a simple abstraction layer.
Install
npm install spotify-application-client
API
isSpotifyRunning
getTrackName
getAlbumName
getArtistName
getPlayerState
getPlayerPositionInSeconds
getTrackDurationInMilliseconds
turnOffRepeat
turnOnRepeat
isRepeating
toggleRepeat
turnOnShuffle
isShuffling
toggleShuffle
togglePlayPause
play
pause
playNextTrack
playPreviousTrack
playTrack(trackId)
playTrackFromAlbum(trackId, albumId)
getTrackDetails
getPlayerDetails
isSpotifyRunning
- Check to see if the Spotify application is running
- Returns a
Promise
containing aBoolean
getTrackName
- Fetch the current track name
- Returns a
Promise
containing the track name as aString
getAlbumName
- Fetch the current album name
- Returns a
Promise
containing the album name as aString
getArtistName
- Fetch the current artist name
- Returns a
Promise
containing the artist name as aString
getPlayerState
- Fetch the Spotify application player state
- The three states are
PLAYING
,PAUSED
,STOPPED
- Returns a
Promise
containing one of these states
getPlayerPositionInSeconds
- Fetch the Spotify application player position, in seconds
- Returns a
Promise
containing aFloat
that describes the player's position, in seconds
getTrackDurationInMilliseconds
- Fetch the current track duration, in milliseconds
- Returns a
Promise
containing anInteger
that describes the current track's duration, in milliseconds
turnOffRepeat
- Turn off the repeat state
- Returns a
Promise
containingnull
if the state change is successful
turnOnRepeat
- Turn on the repeat state
- Returns a
Promise
containingnull
if the state change is successful
isRepeating
- Check if the repeat state is on
- Returns a
Promise
containing aBoolean
toggleRepeat
- Flips the repeat state; if repeat is turned on, turn it off and if its turned off, turn it on
- Returns a
Promise
containingnull
if the state change is successful
turnOffShuffle
- Turn off the shuffle state
- Returns a
Promise
containingnull
if the state change is successful
turnOnShuffle
- Turns on the shuffle state
- Returns a
Promise
containingnull
if the state change is successful
isShuffling
- Check if the shuffle state is on
- Returns a
Promise
containing aBoolean
toggleShuffle
- Flips the shuffle state; if shuffle is turned on, turn it off and if its turned off, turn it on
- Returns a
Promise
containingnull
if the state change is successful
togglePlayPause
- Change the player state between
PLAYING
andPAUSED
; if the player isPLAYING
, then it will bePAUSED
, and if itsPAUSED
, then it will bePLAYING
. - Returns a
Promise
containingnull
if the state change is successful
play
- Change the player state to
PLAYING
- Returns a
Promise
containingnull
if the state change is successful
pause
- Change the player state to
PAUSED
- Returns a
Promise
containingnull
if the state change is successful
playNextTrack
- Plays the next track
- Returns a
Promise
containingnull
if the state change is successful
playPreviousTrack
- Plays the previous track
- Returns a
Promise
containingnull
if the state change is successful
playTrack(trackId)
- Plays a track with a given
trackId
- Returns a
Promise
containingnull
if the state change is successful
playTrackFromAlbum(trackId, albumId)
- Plays a track from an album with a given
trackId
andalbumId
- Returns a
Promise
containingnull
if the state change is successful
getTrackDetails
- Fetches details about the current track
- Returns a
Promise
containing aTrackDetails
object. - The
TrackDetails
object has the following fields:name
: the track namealbumName
: the track's album nameartistName
: the track's artist's nametrackDurationInMilliseconds
: the track's duration in milliseconds
getPlayerDetails
- Fetches details about the player
- Returns a
Promise
a containing aPlayerDetails
object - The
PlayerDetails
object has the following fields:state
: aPlayerState
object (PLAYING
,PAUSED
,STOPPED
)positionInSeconds
: the player's position, in secondsisShuffling
: aBoolean
representing the player's shuffle stateisRepeating
: aBoolean
representing the player's repeat stateisSpotifyRunning
: aBoolean
representing if the Spotify application is active