1.0.5 • Published 8 years ago
spotify-application-client v1.0.5
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
isSpotifyRunninggetTrackNamegetAlbumNamegetArtistNamegetPlayerStategetPlayerPositionInSecondsgetTrackDurationInMillisecondsturnOffRepeatturnOnRepeatisRepeatingtoggleRepeatturnOnShuffleisShufflingtoggleShuffletogglePlayPauseplaypauseplayNextTrackplayPreviousTrackplayTrack(trackId)playTrackFromAlbum(trackId, albumId)getTrackDetailsgetPlayerDetails
isSpotifyRunning
- Check to see if the Spotify application is running
- Returns a
Promisecontaining aBoolean
getTrackName
- Fetch the current track name
- Returns a
Promisecontaining the track name as aString
getAlbumName
- Fetch the current album name
- Returns a
Promisecontaining the album name as aString
getArtistName
- Fetch the current artist name
- Returns a
Promisecontaining the artist name as aString
getPlayerState
- Fetch the Spotify application player state
- The three states are
PLAYING,PAUSED,STOPPED - Returns a
Promisecontaining one of these states
getPlayerPositionInSeconds
- Fetch the Spotify application player position, in seconds
- Returns a
Promisecontaining aFloatthat describes the player's position, in seconds
getTrackDurationInMilliseconds
- Fetch the current track duration, in milliseconds
- Returns a
Promisecontaining anIntegerthat describes the current track's duration, in milliseconds
turnOffRepeat
- Turn off the repeat state
- Returns a
Promisecontainingnullif the state change is successful
turnOnRepeat
- Turn on the repeat state
- Returns a
Promisecontainingnullif the state change is successful
isRepeating
- Check if the repeat state is on
- Returns a
Promisecontaining aBoolean
toggleRepeat
- 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
turnOffShuffle
- Turn off the shuffle state
- Returns a
Promisecontainingnullif the state change is successful
turnOnShuffle
- Turns on the shuffle state
- Returns a
Promisecontainingnullif the state change is successful
isShuffling
- Check if the shuffle state is on
- Returns a
Promisecontaining aBoolean
toggleShuffle
- 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
togglePlayPause
- 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
play
- Change the player state to
PLAYING - Returns a
Promisecontainingnullif the state change is successful
pause
- Change the player state to
PAUSED - Returns a
Promisecontainingnullif the state change is successful
playNextTrack
- Plays the next track
- Returns a
Promisecontainingnullif the state change is successful
playPreviousTrack
- Plays the previous track
- Returns a
Promisecontainingnullif the state change is successful
playTrack(trackId)
- Plays a track with a given
trackId - Returns a
Promisecontainingnullif the state change is successful
playTrackFromAlbum(trackId, albumId)
- Plays a track from an album with a given
trackIdandalbumId - Returns a
Promisecontainingnullif the state change is successful
getTrackDetails
- 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
getPlayerDetails
- 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