Spotify Sdk

admin 11/22/2021
84 Comments

It is a beta release, so there may be changes to the SDK - we’re going to make changes based on the feedback that you and the rest of the developer community share with us. Key Features: Create a Spotify Connect device in your browser. The Spotify App Remote SDK is a set of lightweight objects that connect with the Spotify app and let you control it while all the heavy lifting of playback is offloaded to the Spotify app itself. The Spotify app takes care of playback, networking, offline caching and OS music integration, leaving you to focus on your user experience. Spotify has two versions; one is the standard free version, which lets you stream any song but comes with ads and a set of restrictions that can be removed in the premium version of Spotify. This post will find out how to download Spotify Premium APK and Spotify Lite MOD APK as you always wanted to use Spotify Premium free for life.

  1. Spotify Sdk Ios
  2. Spotify Sdk Flutter
  3. Spotify Sdk Swiftui
Spotify

Description

This is a flutter package that wraps the native iOS and Android Spotify 'remote' SDKs as well as the Spotify Web Playback SDK for web.

Installation

To use this plugin, add spotify_sdk as a dependency in your pubspec.yaml file.

Setup

Android

This package is 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.

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

iOS

Register your app in the spotify developer portal. You also need to register your Bundle ID as well as a Redirect URI.

Follow the instructions in the section Setup the iOS SDK of Spotify iOS SDK Quick Start.

Web

  1. Register your app in the spotify developer portal. You need to provide a redirect URL which points to a dedicated page on a website you own.

  2. Paste the following onto the webpage, which you linked to in your redirect URL.

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.

If you want to use the web api as well you have to use this method to get the authentication token. You can specify multiple scopes by separating them with a comma ',' as shown below. For more information on scopes you can refer to Spotify Authorization Scopes Guide

On iOS you can store the token that you get from getAuthenticationToken(...) and then pass it to connectToSpotifyRemote(...) during the next session. This will avoid having to switch to the Spotify app for establishing the connection. This library does not handle storing the token. It is up to you to persist it wherever you see fit. Keep in mind that this feature is currently quite buggy in the native iOS SDK and has many side effects like random disconnections. Proceed with caution.

On iOS Spotify starts playing music when attempting connection. This is a default behavior and there is no official way to prevent this with the currently supported authentication flows. You have the option to pass a Spotify URI upon connection or set it to a blank string to play the last played song. There is an undocumented workaround if you don't want music to start playing which is to pass an invalid Spotify URI instead. This is not officially supported by the Spotify SDK or this library and it can fail or stop working at any time!

Have a look in the example for detailed insights on how you can use this package.

Api

Connecting/Authenticating

FunctionDescriptionAndroidiOSWeb
connectToSpotifyRemoteConnects the App to Spotify
getAuthenticationTokenGets the Authentication Token that you can use to work with the Web Api
disconnectdisconnects the app connection

Player Api

FunctionDescriptionAndroidiOSWeb
getPlayerStateGets the current player state
pausePauses the current track
playPlays the given spotifyUri
queueQueues given spotifyUri
resumeResumes the current track
skipNextSkips to next track
skipPreviousSkips to previous track
seekToSeeks the current track to the given position in milliseconds🚧
seekToRelativePositionAdds to the current position of the track the given milliseconds🚧
subscribeToPlayerContextSubscribes to the current player context
subscribeToPlayerStateSubscribes to the current player state
getCrossfadeStateGets the current crossfade state
toggleShuffleCycles through the shuffle modes
setShuffleSet the shuffle mode
toggleRepeatCycles through the repeat modes
setRepeatModeSet the repeat mode

Images Api

FunctionDescriptionAndroidiOSWeb
getImageGet the image from the given spotifyUri🚧

User Api

Spotify Sdk Ios

FunctionDescriptionAndroidiOSWeb
addToLibraryAdds the given spotifyUri to the users library🚧
getCapabilitiesGets the current users capabilities🚧🚧
getLibraryStateGets the current library state🚧🚧
removeFromLibraryRemoves the given spotifyUri to the users library🚧
subscribeToCapabilitiesSubscribes to the current users capabilities🚧🚧
subscribeToUserStatusSubscrives to the current users status🚧🚧

Connect Api

FunctionDescriptionAndroidiOSWeb
connectSwitchToLocalDeviceSwitch to play music on this (local) device🚧🚧🚧

Content Api

FunctionDescriptionAndroidiOSWeb
getChildrenOfItemtbd🚧🚧🚧
getRecommendedContentItemstbd🚧🚧🚧
playContentItemtbd🚧🚧🚧

Official Spotify Docs

This SDK must not be used in commercial projects without Spotify's prior written approval

Important: The Web Playback SDK is currently in Beta. The content and functionality may change without warning in future versions.

By using Spotify developer tools, you accept our Developer Terms of Use.They contain important information about what you can and can’t do with our developer tools.Please read them carefully.

About the SDK

The Web Playback SDK is a client-side JavaScript library which allows you to create a new player in Spotify Connect and play any audio track from Spotify in the browser via Encrypted Media Extensions. It’s the same technology we use to power our Web Player experience.

Some things you can do with the Web Playback SDK:

  • Create a new player in Spotify Connect
  • Stream an audio track in supported browsers
  • Get metadata for the current track
  • Get metadata about the user’s listening session
  • Control local playback (pause, resume, volume, etc)

Some things you cannot do with the Web Playback SDK:

  • Download audio / video
  • Manipulate audio / video
  • Authenticate the user with Spotify (Check out Web API using OAuth.)
  • Control playback of other devices (Check out the Connect Web API.)
  • Play a track from a Spotify URI (You can do this through the Web API. Pause/resume can be done inside the SDK.)
  • Access the Web API (You can integrate this separately from our Web API Console.)

Please refer to the Developer Terms of Use for more information about what you can and cannot do with our developer tools.

Requirements

  • A Client ID and Client Secret, which can be obtained from our Dashboard
  • Authenticated users must have a valid Spotify Premium subscription
  • A supported web browser running on the user’s device

Spotify Sdk Flutter

Spotify Sdk

Supported Browsers

Operating SystemBrowsersStatus
Mac/Windows/LinuxChrome, Firefox, IE*✓ Supported
Microsoft Edge✓ Supported
Safari✕ Not Supported
AndroidChrome, Firefox✕ Not Supported
iOSSafari, Chrome✕ Not Supported

Spotify Sdk Swiftui

* IE 11 or above. Must be on Windows 8.1 or above.

Tutorial and Examples

We provide a beginner’s tutorial to help you get started with the Web Playback SDK.It leads you through the creation of a simple web app that makes a Spotify Player instance that can be controlled through Spotify Connect.

API Documentation

The API documentation is available online.

Issues

Please report problems with this SDK through the [public issue tracker][github-issue-tracker] on GitHub.