knurzl / spotify_sdk

Flutter Package to connect the spotify sdk

Home Page:https://pub.dev/packages/spotify_sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Function Description Android iOS
connectToSpotifyRemote Connects the App to Spotify βœ”οΈ πŸ‘·
getAuthenticationToken Gets the Authentication Token that you can use to work with the Web Api βœ”οΈ πŸ‘·
logout logs the user out and disconnects the app connection πŸ‘· πŸ‘·

Player Api

Function Description Android iOS
getCrossfadeState Gets the current crossfade state βœ”οΈ πŸ‘·
getPlayerState Gets the current player state βœ”οΈ πŸ‘·
pause Pauses the current track βœ”οΈ πŸ‘·
play Plays the given spotifyUri βœ”οΈ πŸ‘·
queue Queues given spotifyUri βœ”οΈ πŸ‘·
resume Resumes the current track βœ”οΈ πŸ‘·
skipNext Skips to next track βœ”οΈ πŸ‘·
skipPrevious Skips to previous track βœ”οΈ πŸ‘·
seekTo Seeks the current track to the given position in milliseconds βœ”οΈ πŸ‘·
seekToRelativePosition Adds to the current position of the track the given milliseconds βœ”οΈ πŸ‘·
subscribeToPlayerContext Subscribes to the current player context βœ”οΈ πŸ‘·
subscribeToPlayerState Subscribes to the current player state βœ”οΈ πŸ‘·
getCrossfadeState Gets the current crossfade state βœ”οΈ πŸ‘·
toggleShuffle Cycles through the shuffle modes βœ”οΈ πŸ‘·
toggleRepeat Cycles through the repeat modes βœ”οΈ πŸ‘·

Images Api

Function Description Android iOS
getImage Get the image from the given spotifyUri βœ”οΈ πŸ‘·

User Api

Function Description Android iOS
addToLibrary Adds the given spotifyUri to the users library βœ”οΈ πŸ‘·
getCapabilities Gets the current users capabilities βœ”οΈ πŸ‘·
getLibraryState Gets the current library state βœ”οΈ πŸ‘·
removeFromLibrary Removes the given spotifyUri to the users library βœ”οΈ πŸ‘·
subscribeToCapabilities Subscribes to the current users capabilities βœ”οΈ πŸ‘·
subscribeToUserStatus Subscrives to the current users status βœ”οΈ πŸ‘·

Connect Api

Function Description Android iOS
connectSwitchToLocalDevice Switch to play music on this (local) device πŸ‘· πŸ‘·

Content Api

Function Description Android iOS
getChildrenOfItem tbd πŸ‘· πŸ‘·
getRecommendedContentItems tbd πŸ‘· πŸ‘·
playContentItem tbd πŸ‘· πŸ‘·

Official Spotify Docs

About

Flutter Package to connect the spotify sdk

https://pub.dev/packages/spotify_sdk

License:MIT License


Languages

Language:Dart 55.1%Language:Kotlin 41.8%Language:Swift 1.1%Language:Ruby 1.1%Language:Objective-C 0.9%