spotify_sdk

pub package Test and Build licence

Description

This will be a spotify_sdk package for flutter using both the spotify-app-remote sdk and spotify-auth library. The auth library is needed to get the authentication token to work with the web api.

Setup

Android

From the Spotify Android SDK Quick Start. You need two things:

  1. register your app in the spotify developer portal. You also need to create a sha-1 fingerprint and add this and your package name to the app settings on the dashboard as well as a redirect url.
  2. download the current Spotify Android SDK. Here you need the spotify-app-remote-.aar and spotify-auth-.aar.

After you are all setup you need to add the *.aar files to your Android Project as Modules. See the Spotify Android SDK Quick Start for detailed information.

Important here is the naming so that the package can find the modules.

  • Remote: spotify-app-remote
  • Auth: spotify-auth

Usage

To start using this package you first have to connect to Spotify. To only connect you can do this with connectToSpotifyRemote(...) or getAuthenticationToken(...) in both of these methods you need the client id, given in the spotify dashboard and the redirect url you set in the settings on the dashboard.

await SpotifySdk.connectToSpotifyRemote(clientId: "", redirectUrl: "")

If you want to use the web api aswell you have to use this method to get the authentication token.

var authenticationToken = await SpotifySdk.getAuthenticationToken(clientId: "", redirectUrl: "");

tbd...

Have a look here for a more detailed example.

Api

Connecting/Authenticating

FunctionDescriptionAndroidiOS
connectToSpotifyRemoteConnects the App to Spotify:heavy_check_mark::construction_worker:
getAuthenticationTokenGets the Authentication Token that you can use to work with the Web Api:heavy_check_mark::construction_worker:
logoutlogs the user out and disconnects the app connection:construction_worker::construction_worker:

Player Api

FunctionDescriptionAndroidiOS
getCrossfadeStateGets the current crossfade state:heavy_check_mark::construction_worker:
getPlayerStateGets the current player state:heavy_check_mark::construction_worker:
pausePauses the current track:heavy_check_mark::construction_worker:
playPlays the given spotifyUri:heavy_check_mark::construction_worker:
queueQueues given spotifyUri:heavy_check_mark::construction_worker:
resumeResumes the current track:heavy_check_mark::construction_worker:
skipNextSkips to next track:heavy_check_mark::construction_worker:
skipPreviousSkips to previous track:heavy_check_mark::construction_worker:
seekToSeeks the current track to the given position in milliseconds:heavy_check_mark::construction_worker:
seekToRelativePositionAdds to the current position of the track the given milliseconds:heavy_check_mark::construction_worker:
subscribeToPlayerContextSubscribes to the current player context:heavy_check_mark::construction_worker:
subscribeToPlayerStateSubscribes to the current player state:heavy_check_mark::construction_worker:
getCrossfadeStateGets the current crossfade state:heavy_check_mark::construction_worker:
toggleShuffleCycles through the shuffle modes:heavy_check_mark::construction_worker:
toggleRepeatCycles through the repeat modes:heavy_check_mark::construction_worker:

Images Api

FunctionDescriptionAndroidiOS
getImageGet the image from the given spotifyUri:heavy_check_mark::construction_worker:

User Api

FunctionDescriptionAndroidiOS
addToLibraryAdds the given spotifyUri to the users library:heavy_check_mark::construction_worker:
getCapabilitiesGets the current users capabilities:heavy_check_mark::construction_worker:
getLibraryStateGets the current library state:heavy_check_mark::construction_worker:
removeFromLibraryRemoves the given spotifyUri to the users library:heavy_check_mark::construction_worker:
subscribeToCapabilitiesSubscribes to the current users capabilities:heavy_check_mark::construction_worker:
subscribeToUserStatusSubscrives to the current users status:heavy_check_mark::construction_worker:

Connect Api

FunctionDescriptionAndroidiOS
connectSwitchToLocalDeviceSwitch to play music on this (local) device:construction_worker::construction_worker:

Content Api

FunctionDescriptionAndroidiOS
getChildrenOfItemtbd:construction_worker::construction_worker:
getRecommendedContentItemstbd:construction_worker::construction_worker:
playContentItemtbd:construction_worker::construction_worker:

Official Spotify Docs

Libraries

album
artist
capabilities
connection_status
crossfade_state
image_uri
library_state
player_context
player_options
player_restrictions
player_state
spotify_sdk
track
user_status