Skip to content
Tim Flapper edited this page May 4, 2014 · 33 revisions

Cordova Spotify Plugin API

Table of Contents

spotify API

spotify.Session API

spotify.AudioPlayer API

spotify.Playlist API

spotify.Album API

spotify.Artist API

spotify.Track API

spotify

Methods

spotify.authenticate

Authenticate the user with the Spotify API

spotify.authenticate(clientId, tokenExchangeURL, [scopes], callback)

clientId string

the clientId supplied by Spotify.

tokenExchangeURL string

The URL for your token exchange service. See setting up a token exchange service

scopes [optional] array

Custom scopes to request from the Spotify authentication service

callback function

The callback gets two arguments error and session. session is a spotifySession object.

spotify.search

spotify.getPlaylistsForUser

spotify.Session

Normally a spotify.Session object is returned from spotify.authenticate() but you can use the spotify.Session object to store the session for later use. A session is valid for 24 hours after which the user will need to login again.

var session = spotify.Session({username: 'someUsername', credentials: 'AFD42....GD43'});

Properties

session.username

The username of the user.

session.credential

An access token to verify the session.

spotify.AudioPlayer

The constructor for a new spotify.AudioPlayer object.

spotify.AudioPlayer(companyName, appName, session, callback)

companyName string

Your company name

appName string

Your application name

session object

The user's spotify.Session object.

callback function

The callback gets two arguments error and an spotify.AudioPlayer object, ready to start playing tracks.

Example

These examples show how to construct a spotify.AudioPlayer and play a track.

spotify.AudioPlayer('Your-Company-Name', 'Your-App-Name', session, function(error, audioPlayer) {
	audioPlayer.playURI('spotify:track:6JEK0CvvjDjjMUBFoXShNZ');
});

Methods

audioPlayer.addEventListener

audioPlayer.playURI

audioPlayer.seekToOffset

audioPlayer.getIsPlaying

audioPlayer.setIsPlaying

audioPlayer.setVolume

audioPlayer.getLoggedIn

audioPlayer.getCurrentTrack

audioPlayer.getCurrentPlaybackPosition

Events

login

logout

permissionLost

error

message

playbackStatus

seekToOffset

spotify.Playlist

Methods

playlist.setName

playlist.setDescription

playlist.setCollaborative

playlist.addTracks

playlist.delete

Properties

playlist.name

playlist.version

playlist.uri

playlist.collaborative

playlist.creator

playlist.tracks

playlist.dateModified

spotify.Album

Properties

album.name

album.uri

album.sharingURL

album.externalIds

album.availableTerritories

album.artists

album.tracks

album.releaseDate

album.type

album.genres

album.covers

album.largestCover

album.smallestCover

album.popularity

spotify.Artist

Properties

artist.name

artist.uri

artist.sharingURL

artist.genres

artist.images

artist.smallestImage

artist.largestImage

artist.popularity

spotify.Track

Properties

track.name

track.uri

track.sharingURL

track.previewURL

track.duration

track.artists

track.album

track.trackNumber

track.discNumber

track.popularity

track.flaggedExplicit

track.externalIds

track.availableTerritories

Clone this wiki locally