Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
brim-borium committed Jul 8, 2020
2 parents 30afe78 + cf7ed9c commit f74df9d
Show file tree
Hide file tree
Showing 17 changed files with 1,183 additions and 235 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ build/
.classpath
.settings
.env*
*.sqlite
/.vs/spotify_sdk/v16/.suo
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.5.0
* adds support for web (thanks [itsMatoosh](https://github.com/itsMatoosh))
* adds custom scopes for the web api (thanks [arnav-sh](https://github.com/arnav-sh))
* adds logout functionality for android
* moved from [pedantic](https://pub.dev/packages/pedantic) to [lint](https://pub.dev/packages/lint) for static analyses
* some minor bug fixing

## 0.3.4

* adds handling of unexpected disconnects from Spotify via subscribeConnectionStatus()-Stream(thanks [itsMatoosh](https://github.com/itsMatoosh))
Expand Down
140 changes: 90 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# spotify_sdk

[![pub package](https://img.shields.io/badge/pub-0.3.4-orange)](https://pub.dev/packages/spotify_sdk)
[![Test and Build](https://github.com/brim-borium/spotify_sdk/workflows/Test%20and%20Build/badge.svg?branch=develop)](https://github.com/brim-borium/spotify_sdk/actions)
[![pub package](https://img.shields.io/badge/pub-0.5.0-orange)](https://pub.dev/packages/spotify_sdk)
[![Dry Run](https://github.com/brim-borium/spotify_sdk/workflows/Dry%20Run/badge.svg?branch=develop)](https://github.com/brim-borium/spotify_sdk/actions?query=workflow%3A%22Dry+Run%22)
[![licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/IamTobi/spotify_sdk/blob/master/LICENSE)

## Description
Expand All @@ -14,7 +14,7 @@ This will be a spotify_sdk package for flutter using both the spotify-app-remote

From the [Spotify Android SDK Quick Start](https://developer.spotify.com/documentation/android/quick-start/). You need two things:

1. register your app in the [spotify developer portal](https://developer.spotify.com/dashboard/). 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.
1. Register your app in the [spotify developer portal](https://developer.spotify.com/dashboard/). 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](https://github.com/spotify/android-sdk/releases). 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](https://developer.spotify.com/documentation/android/quick-start/) for detailed information.
Expand All @@ -24,84 +24,124 @@ Important here is the naming so that the package can find the modules.
- Remote: spotify-app-remote
- Auth: spotify-auth

### Web

1. Register your app in the [spotify developer portal](https://developer.spotify.com/dashboard/). 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.
```html
<!DOCTYPE html>
<html>
<head>
<title>Authenticating Spotify</title>
</head>
<body>
<p>Please wait while we authenticate Spotify...</p>
<script type="text/javascript">
if(window.opener) {
var error = getParameterByName('error');
if(error) {
window.opener.postMessage('?' + error, "*");
} else {
window.opener.postMessage(window.location.hash, "*");
}
} else {
window.close();
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
</script>
</body>
</html>
```

[You need Spotify Premium to access the Web SDK.](https://developer.spotify.com/documentation/web-playback-sdk/quick-start/)

## 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.

```dart
await SpotifySdk.connectToSpotifyRemote(clientId: "", redirectUrl: "")
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.
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](https://developer.spotify.com/documentation/general/guides/scopes/)

```dart
var authenticationToken = await SpotifySdk.getAuthenticationToken(clientId: "", redirectUrl: "");
var authenticationToken = await SpotifySdk.getAuthenticationToken(clientId: "", redirectUrl: "", scope: "app-remote-control,user-modify-playback-state,playlist-read-private");
```

tbd...

Have a look [here](example/lib/main.dart) for a more detailed example.
Have a look [in the example](example/lib/main.dart) for detailed insights on how you can use this package.

### Api

#### Connecting/Authenticating

| Function | Description| Android | iOS |
|---|---|---|--|
| connectToSpotifyRemote | Connects the App to Spotify | :heavy_check_mark: | :construction_worker: |
| getAuthenticationToken | Gets the Authentication Token that you can use to work with the [Web Api](https://developer.spotify.com/documentation/web-api/) |:heavy_check_mark: | :construction_worker: |
| logout | logs the user out and disconnects the app connection |:construction_worker: | :construction_worker: |
| Function | Description| Android | iOS | Web |
|---|---|---|---|---|
| connectToSpotifyRemote | Connects the App to Spotify | :heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| getAuthenticationToken | Gets the Authentication Token that you can use to work with the [Web Api](https://developer.spotify.com/documentation/web-api/) |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| logout | logs the user out and disconnects the app connection |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |

#### Player Api

| Function | Description| Android | iOS |
|---|---|---|--|
| getCrossfadeState | Gets the current crossfade state |:heavy_check_mark: | :construction_worker: |
| getPlayerState | Gets the current player state |:heavy_check_mark: | :construction_worker: |
| pause | Pauses the current track |:heavy_check_mark: | :construction_worker: |
| play | Plays the given spotifyUri |:heavy_check_mark: | :construction_worker: |
| queue | Queues given spotifyUri |:heavy_check_mark: | :construction_worker: |
| resume | Resumes the current track |:heavy_check_mark: | :construction_worker: |
| skipNext | Skips to next track | :heavy_check_mark: | :construction_worker: |
| skipPrevious | Skips to previous track |:heavy_check_mark: | :construction_worker: |
| seekTo | Seeks the current track to the given position in milliseconds | :heavy_check_mark: |:construction_worker: |
| seekToRelativePosition | Adds to the current position of the track the given milliseconds |:heavy_check_mark: | :construction_worker: |
| subscribeToPlayerContext | Subscribes to the current player context |:heavy_check_mark:|:construction_worker: |
| subscribeToPlayerState| Subscribes to the current player state |:heavy_check_mark: |:construction_worker:|
| getCrossfadeState | Gets the current crossfade state |:heavy_check_mark: | :construction_worker: |
| toggleShuffle | Cycles through the shuffle modes |:heavy_check_mark: | :construction_worker: |
| toggleRepeat | Cycles through the repeat modes | :heavy_check_mark: | :construction_worker: |
| Function | Description | Android | iOS | Web |
|---|---|---|---|---|
| getCrossfadeState | Gets the current crossfade state | :heavy_check_mark: | :construction_worker: | :x: |
| getPlayerState | Gets the current player state |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| pause | Pauses the current track |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| play | Plays the given spotifyUri |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| queue | Queues given spotifyUri |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| resume | Resumes the current track |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| skipNext | Skips to next track | :heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| skipPrevious | Skips to previous track |:heavy_check_mark: | :construction_worker: | :heavy_check_mark: |
| seekTo | Seeks the current track to the given position in milliseconds | :heavy_check_mark: |:construction_worker: | :construction_worker: |
| seekToRelativePosition | Adds to the current position of the track the given milliseconds |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| subscribeToPlayerContext | Subscribes to the current player context |:heavy_check_mark:|:construction_worker: | :heavy_check_mark: |
| subscribeToPlayerState| Subscribes to the current player state |:heavy_check_mark: |:construction_worker:| :heavy_check_mark: |
| getCrossfadeState | Gets the current crossfade state |:heavy_check_mark: | :construction_worker: | :x: |
| toggleShuffle | Cycles through the shuffle modes |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| toggleRepeat | Cycles through the repeat modes | :heavy_check_mark: | :construction_worker: | :construction_worker: |

#### Images Api

| Function | Description| Android | iOS |
|---|---|---|--|
| getImage | Get the image from the given spotifyUri |:heavy_check_mark: | :construction_worker: |
| Function | Description| Android | iOS | Web |
|---|---|---|---|---|
| getImage | Get the image from the given spotifyUri |:heavy_check_mark: | :construction_worker: | :construction_worker: |

#### User Api

| Function | Description| Android | iOS |
|---|---|---|--|
| addToLibrary | Adds the given spotifyUri to the users library |:heavy_check_mark: | :construction_worker: |
| getCapabilities | Gets the current users capabilities |:heavy_check_mark: | :construction_worker: |
| getLibraryState | Gets the current library state |:heavy_check_mark: | :construction_worker: |
| removeFromLibrary | Removes the given spotifyUri to the users library |:heavy_check_mark: | :construction_worker: |
| subscribeToCapabilities | Subscribes to the current users capabilities |:heavy_check_mark: | :construction_worker: |
| subscribeToUserStatus | Subscrives to the current users status |:heavy_check_mark: | :construction_worker: |
| Function | Description| Android | iOS | Web |
|---|---|---|---|---|
| addToLibrary | Adds the given spotifyUri to the users library |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| getCapabilities | Gets the current users capabilities |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| getLibraryState | Gets the current library state |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| removeFromLibrary | Removes the given spotifyUri to the users library |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| subscribeToCapabilities | Subscribes to the current users capabilities |:heavy_check_mark: | :construction_worker: | :construction_worker: |
| subscribeToUserStatus | Subscrives to the current users status |:heavy_check_mark: | :construction_worker: | :construction_worker: |

#### Connect Api

| Function | Description| Android | iOS |
|---|---|---|--|
| connectSwitchToLocalDevice | Switch to play music on this (local) device |:construction_worker: | :construction_worker: |
| Function | Description| Android | iOS | Web |
|---|---|---|---|---|
| connectSwitchToLocalDevice | Switch to play music on this (local) device |:construction_worker: | :construction_worker: | :construction_worker: |

#### Content Api

| Function | Description| Android | iOS |
|---|---|---|--|
| getChildrenOfItem | tbd |:construction_worker: | :construction_worker: |
| getRecommendedContentItems | tbd |:construction_worker: | :construction_worker: |
| playContentItem | tbd |:construction_worker: | :construction_worker: |
| Function | Description| Android | iOS | Web |
|---|---|---|---|---|
| getChildrenOfItem | tbd |:construction_worker: | :construction_worker: | :construction_worker: |
| getRecommendedContentItems | tbd |:construction_worker: | :construction_worker: | :construction_worker: |
| playContentItem | tbd |:construction_worker: | :construction_worker: | :construction_worker: |

## Official Spotify Docs

Expand Down
16 changes: 8 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
include: package:pedantic/analysis_options.yaml
include: package:lint/analysis_options_package.yaml

linter:
rules:
# ------ Disable individual rules ----- #
# --- #
# Turn off what you don't like. #
# ------------------------------------- #
rules:
# ------ Disable individual rules ----- #
# --- #
# Turn off what you don't like. #
# ------------------------------------- #

analyzer:
exclude:
exclude:
# Ignore generated files
- '**/*.g.dart'
- 'lib/src/generated/*.dart'
Loading

0 comments on commit f74df9d

Please sign in to comment.