Node Client for the Spotify App on Mac OS
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.
npm install spotify-application-client
isSpotifyRunninggetTrackNamegetAlbumNamegetArtistNamegetPlayerStategetPlayerPositionInSecondsgetTrackDurationInMillisecondsturnOffRepeatturnOnRepeatisRepeatingtoggleRepeatturnOnShuffleisShufflingtoggleShuffletogglePlayPauseplaypauseplayNextTrackplayPreviousTrackplayTrack(trackId)playTrackFromAlbum(trackId, albumId)getTrackDetailsgetPlayerDetails
- Check to see if the Spotify application is running
- Returns a
Promisecontaining aBoolean
- Fetch the current track name
- Returns a
Promisecontaining the track name as aString
- Fetch the current album name
- Returns a
Promisecontaining the album name as aString
- Fetch the current artist name
- Returns a
Promisecontaining the artist name as aString
- Fetch the Spotify application player state
- The three states are
PLAYING,PAUSED,STOPPED - Returns a
Promisecontaining one of these states
- Fetch the Spotify application player position, in seconds
- Returns a
Promisecontaining aFloatthat describes the player's position, in seconds
- Fetch the current track duration, in milliseconds
- Returns a
Promisecontaining anIntegerthat describes the current track's duration, in milliseconds
- Turn off the repeat state
- Returns a
Promisecontainingnullif the state change is successful
- Turn on the repeat state
- Returns a
Promisecontainingnullif the state change is successful
- Check if the repeat state is on
- Returns a
Promisecontaining aBoolean
- Flips the repeat state; if repeat is turned on, turn it off and if its turned off, turn it on
- Returns a
Promisecontainingnullif the state change is successful
- Turn off the shuffle state
- Returns a
Promisecontainingnullif the state change is successful
- Turns on the shuffle state
- Returns a
Promisecontainingnullif the state change is successful
- Check if the shuffle state is on
- Returns a
Promisecontaining aBoolean
- Flips the shuffle state; if shuffle is turned on, turn it off and if its turned off, turn it on
- Returns a
Promisecontainingnullif the state change is successful
- Change the player state between
PLAYINGandPAUSED; if the player isPLAYING, then it will bePAUSED, and if itsPAUSED, then it will bePLAYING. - Returns a
Promisecontainingnullif the state change is successful
- Change the player state to
PLAYING - Returns a
Promisecontainingnullif the state change is successful
- Change the player state to
PAUSED - Returns a
Promisecontainingnullif the state change is successful
- Plays the next track
- Returns a
Promisecontainingnullif the state change is successful
- Plays the previous track
- Returns a
Promisecontainingnullif the state change is successful
- Plays a track with a given
trackId - Returns a
Promisecontainingnullif the state change is successful
- Plays a track from an album with a given
trackIdandalbumId - Returns a
Promisecontainingnullif the state change is successful
- Fetches details about the current track
- Returns a
Promisecontaining aTrackDetailsobject. - The
TrackDetailsobject 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
- Fetches details about the player
- Returns a
Promisea containing aPlayerDetailsobject - The
PlayerDetailsobject has the following fields:state: aPlayerStateobject (PLAYING,PAUSED,STOPPED)positionInSeconds: the player's position, in secondsisShuffling: aBooleanrepresenting the player's shuffle stateisRepeating: aBooleanrepresenting the player's repeat stateisSpotifyRunning: aBooleanrepresenting if the Spotify application is active