Skip to content

Commit d1a1f5f

Browse files
authored
Merge pull request #43 from cjam/feat/android-support
Feat/android support
2 parents 39899b9 + 8c76d44 commit d1a1f5f

File tree

92 files changed

+9090
-3234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+9090
-3234
lines changed

.all-contributorsrc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"projectName": "react-native-spotify-remote",
3+
"projectOwner": "cjam",
4+
"repoType": "github",
5+
"repoHost": "https://github.com",
6+
"files": [
7+
"README.md"
8+
],
9+
"imageSize": 100,
10+
"commit": false,
11+
"commitConvention": "none",
12+
"contributors": [
13+
{
14+
"login": "cjam",
15+
"name": "Colter McQuay",
16+
"avatar_url": "https://avatars2.githubusercontent.com/u/1000288?v=4",
17+
"profile": "https://github.com/cjam",
18+
"contributions": [
19+
"code"
20+
]
21+
},
22+
{
23+
"login": "lufinkey",
24+
"name": "Luis Finke",
25+
"avatar_url": "https://avatars3.githubusercontent.com/u/7820113?v=4",
26+
"profile": "https://github.com/lufinkey",
27+
"contributions": [
28+
"ideas"
29+
]
30+
},
31+
{
32+
"login": "YozhikM",
33+
"name": "Stanislav",
34+
"avatar_url": "https://avatars0.githubusercontent.com/u/27273025?v=4",
35+
"profile": "https://github.com/YozhikM",
36+
"contributions": [
37+
"code"
38+
]
39+
}
40+
],
41+
"contributorsPerLine": 7
42+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ project.xcworkspace
3838

3939
# Android/IntelliJ
4040
#
41+
android/.project
42+
android/.settings
4143
/android/gradle/
4244
gradlew
4345
gradlew.bat
@@ -46,6 +48,9 @@ build/
4648
.gradle
4749
local.properties
4850
*.iml
51+
example/android/.project
52+
example/android/.settings
53+
*.aab
4954

5055
# BUCK
5156
buck-out/

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
path = ios/external/SpotifySDK
33
url = https://github.com/spotify/ios-sdk.git
44
ignore = dirty
5+
[submodule "android/external/SpotifySDK"]
6+
path = android/external/SpotifySDK
7+
url = https://github.com/spotify/android-sdk.git
8+
ignore = dirty

.npmignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
/ios/external/SpotifySDK/docs
55
/ios/external/SpotifySDK/DemoProjects
66
/ios/external/SpotifySDK/img
7-
/android/gradle/
7+
/android/.gradle/
8+
/android/build/
9+
/android/external/SpotifySDK/app-remote-sample
10+
/android/external/SpotifySDK/auth-sample
11+
/android/external/SpotifySDK/app-remote-lib/docs
12+
/android/external/SpotifySDK/app-remote-lib/img
13+
/android/external/SpotifySDK/auth-lib/docs
14+
/android/external/SpotifySDK/*.*
15+
/src/
816
gradlew
917
gradlew.bat
1018
build/
19+
gradlew
20+
gradlew.bat
1121
.idea
12-
.gradle
1322
local.properties
1423
*.iml

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66
## [Unreleased]
7+
### Changed
8+
- `ApiConfig.scope` to `ApiConfig.scopes` which is now of type `ApiScope[]` and also aligns to the web api scopes
9+
- `ApiScope` enum values are now same as web api instead of bit flags
10+
- `PlayerState.paused` -> `PlayerState.isPaused` to align with Spotify's iOS/Android sdk's
11+
12+
### Added
13+
- Android Support! Big thanks to @YozhikM for the initial work on this
14+
- `PlaybackRestrictions.canSeek`
15+
- `SpotifyRemote.getChildrenOfItem` now has optional `options:GetChildrenItemsOptions` for android paging
16+
- `SpotifyAuth.authorize` to replace `SpotifyAuth.initialize` which will now return a session object instead of just a token
17+
18+
### Deprecated
19+
- `SpotifyAuth.initialize` in favor of `SpotifyAuth.authorize`
20+
21+
### Removed
22+
723

824
## [0.2.2] - 2020-03-22
925
### Changed

README.md

Lines changed: 80 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,54 @@
11

22
# Spotify App Remote for React Native
33

4-
A react native module for the Spotify Remote SDK.
4+
[![npm version](https://badge.fury.io/js/react-native-spotify-remote.svg)](https://badge.fury.io/js/react-native-spotify-remote)
55

6-
>## ⚠️ Work In Progress ⚠️
7-
8-
>## Currently Only Implemented for iOS
6+
A react native module for the Spotify Remote SDK ( [iOS](https://github.com/spotify/ios-sdk/) | [Android](https://github.com/spotify/android-sdk/) )
97

108
- [Documentation](https://cjam.github.io/react-native-spotify-remote/index.html)
119
- [Change Log](./CHANGELOG.md)
1210
- [Contributing](./CONTRIBUTING.md)
1311

12+
## Supported Features
13+
14+
An [Example](./example) project was developed to exercise and test all functionality within this library. If you are curious about how to use something, or need to compare your application setup to something that works, check there first.
15+
16+
## Features
17+
18+
The following table shows the platform support for various Spotify Remote API functionality within this library.
19+
20+
|Feature|iOS|Android||
21+
|:--|:-:|:-:|-:|
22+
|Authentication|
23+
|`authorize` ||||
24+
|`getSession` ||||
25+
|`endSession` ||||
26+
|Remote|
27+
|`isConnectedAsync` ||||
28+
|`connect` ||||
29+
|`disconnect` ||||
30+
|`playUri` ||||
31+
|`playItem` ||||
32+
|`playItemWithIndex` ||||
33+
|`queueUri` ||||
34+
|`seek` ||||
35+
|`resume` ||||
36+
|`pause` ||||
37+
|`skipToNext` ||||
38+
|`skipToPrevious` ||||
39+
|`setShuffling` ||||
40+
|`setRepeatMode` ||||
41+
|`getPlayerState` ||||
42+
|`getRootContentItems` |||Not available in Android SDK|
43+
|`getRecommendedContentItems` ||||
44+
|`getChildrenOfItem` ||||
45+
|`getContentItemForUri` |||Not available in Android SDK|
46+
|`getCrossfadeState` ||||
47+
|Remote Events|
48+
|`playerStateChanged` ||||
49+
|`remoteDisconnected` ||||
50+
|`remoteConnected` ||||
51+
1452
## Install
1553

1654
```bash
@@ -25,6 +63,8 @@ npm install --save react-native-spotify-remote
2563

2664
## Linking
2765

66+
As of React Native `> 0.61`, auto linking should work for both iOS and Android. There shouldn't be any modifications necessary and it *Should* work out of the box. The one caveat, is that `react-native-events` needs to be linked as it doesn't yet support auto linking. If you do run into issues or are using an older version of React Native, the following sections should help get you up and running.
67+
2868
### iOS
2969

3070
>This library requires being built with **XCode 11** for reasons given [here](https://github.com/spotify/ios-sdk/issues/179#issuecomment-581032275).
@@ -85,102 +125,34 @@ Modifications are needed for the `AppDelegate.m`:
85125
@end
86126
```
87127
88-
<!--
89-
#### Android
128+
### Android
129+
130+
If you need to link your project manually, here are some things you'll need to do.
90131
91-
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
132+
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
92133
- Add `import com.reactlibrary.RNSpotifyRemotePackage;` to the imports at the top of the file
93134
- Add `new RNSpotifyRemotePackage()` to the list returned by the `getPackages()` method
94135
2. Append the following lines to `android/settings.gradle`:
95136
```
96-
include ':react-native-spotify-remote'
97-
project(':react-native-spotify-remote').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spotify-remote/android')
137+
include ':react-native-spotify-remote'
138+
project(':react-native-spotify-remote').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spotify-remote/android')
139+
140+
include ':react-native-events'
141+
project(':react-native-events').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-events/android')
98142
```
99143
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
100144
```
101-
compile project(':react-native-spotify-remote')
145+
implementation project(':react-native-spotify-remote')
146+
implementation project(':react-native-events')
102147
```
103148
104-
Edit `android/build.gradle` and add `flatDir`
105-
106-
```
107-
...
108-
allprojects {
109-
repositories {
110-
mavenLocal()
111-
jcenter()
112-
maven {
113-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
114-
url "$rootDir/../node_modules/react-native/android"
115-
}
116-
flatDir {
117-
dirs project(':react-native-spotify-remote').file('libs'), 'libs'
118-
}
119-
}
120-
}
121-
...
122-
```
123-
124-
Edit `android/app/build.gradle` and add `packagingOptions`
125-
126-
```
127-
...
128-
buildTypes {
129-
release {
130-
minifyEnabled enableProguardInReleaseBuilds
131-
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
132-
}
133-
}
134-
packagingOptions {
135-
pickFirst 'lib/armeabi-v7a/libgnustl_shared.so'
136-
pickFirst 'lib/x86/libgnustl_shared.so'
137-
}
138-
...
139-
```
140-
141149
If you have issues linking the module, please check that gradle is updated to the latest version and that your project is synced. -->
142150
143-
## Features
144-
145-
The following table is here to show the support for Spotify Remote API functionality within this library.
146-
147-
|Feature|iOS|Android|
148-
|:--|:-:|:-:|
149-
|Authentication|
150-
|`initialize`|[x]|[ ]|
151-
|`getSession`|[x]|[ ]|
152-
|`endSession`|[x]|[ ]|
153-
|Remote|
154-
|`isConnectedAsync`|[x]|[ ]|
155-
|`connect`|[x]|[ ]|
156-
|`playUri`|[x]|[ ]|
157-
|`playItem`|[x]|[ ]|
158-
|`playItemWithIndex`|[x]|[ ]|
159-
|`queueUri`|[x]|[ ]|
160-
|`seek`|[x]|[ ]|
161-
|`resume`|[x]|[ ]|
162-
|`pause`|[x]|[ ]|
163-
|`skipToNext`|[x]|[ ]|
164-
|`skipToPrevious`|[x]|[ ]|
165-
|`setShuffling`|[x]|[ ]|
166-
|`setRepeatMode`|[x]|[ ]|
167-
|`getPlayerState`|[x]|[ ]|
168-
|`getRootContentItems`|[x]|[ ]|
169-
|`getRecommendedContentItems`|[x]|[ ]|
170-
|`getChildrenOfItem`|[x]|[ ]|
171-
|`getContentItemForUri`|[x]|[ ]|
172-
|`getCrossfadeState`|[x]|[ ]|
173-
|Remote Events|
174-
|`playerStateChanged`|[x]|[ ]|
175-
|`remoteDisconnected`|[x]|[ ]|
176-
|`remoteConnected`|[x]|[ ]|
177-
178-
179151
## Usage
180152
181153
### Example Application
182154
183-
This repo contains an [Example App](./example/Readme.md) which should be the quickest and easiest way to get up and running to try things out. It is using React Hooks (cuz they're pretty cool) and is using a few of the remote API calls. (Will be looking to show use of all of the api calls in the near future).
155+
This repo contains an [Example App](./example/Readme.md) which should be the quickest and easiest way to get up and running to try things out. It is using React Hooks (cuz they're pretty cool) and exercises all of the remote API calls.
184156
185157
### In Code
186158
@@ -202,15 +174,15 @@ const spotifyConfig: ApiConfig = {
202174
redirectURL: "SPOTIFY_REDIRECT_URL",
203175
tokenRefreshURL: "SPOTIFY_TOKEN_REFRESH_URL",
204176
tokenSwapURL: "SPOTIFY_TOKEN_SWAP_URL",
205-
scope: ApiScope.AppRemoteControlScope | ApiScope.UserFollowReadScope
177+
scopes: [ApiScope.AppRemoteControlScope, ApiScope.UserFollowReadScope]
206178
}
207179
208180
// Initialize the library and connect the Remote
209181
// then play an epic song
210182
async function playEpicSong(){
211183
try{
212-
const token = await SpotifyAuth.initialize(spotifyConfig);
213-
await SpotifyRemote.connect(token);
184+
const session = await SpotifyAuth.authorize(spotifyConfig);
185+
await SpotifyRemote.connect(session.token);
214186
await remote.playUri("spotify:track:6IA8E2Q5ttcpbuahIejO74");
215187
await remote.seek(58000);
216188
}catch(err){
@@ -235,6 +207,25 @@ Nothing has been special to deal with Spotify *Free* Users but this module _shou
235207

236208
Please do not open issues about getting the module to work unless you have tried using both the example app and the example token swap server. Please make sure you have tried running on the latest react-native version before submitting a bug.
237209

238-
## Acknowledgements
210+
## Contributors
211+
212+
Big thanks to [@lufinkey](https://github.com/lufinkey) and all of the great work that he has done in the [react-native-spotify](https://github.com/lufinkey/react-native-spotify) repo which was the original source of inspiration and some useful patterns for this package.
213+
214+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
215+
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
216+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
217+
218+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
219+
<!-- prettier-ignore-start -->
220+
<!-- markdownlint-disable -->
221+
<table>
222+
<tr>
223+
<td align="center"><a href="https://github.com/cjam"><img src="https://avatars2.githubusercontent.com/u/1000288?v=4" width="100px;" alt=""/><br /><sub><b>Colter McQuay</b></sub></a><br /><a href="https://github.com/cjam/react-native-spotify-remote/commits?author=cjam" title="Code">💻</a></td>
224+
<td align="center"><a href="https://github.com/lufinkey"><img src="https://avatars3.githubusercontent.com/u/7820113?v=4" width="100px;" alt=""/><br /><sub><b>Luis Finke</b></sub></a><br /><a href="#ideas-lufinkey" title="Ideas, Planning, & Feedback">🤔</a></td>
225+
<td align="center"><a href="https://github.com/YozhikM"><img src="https://avatars0.githubusercontent.com/u/27273025?v=4" width="100px;" alt=""/><br /><sub><b>Stanislav</b></sub></a><br /><a href="https://github.com/cjam/react-native-spotify-remote/commits?author=YozhikM" title="Code">💻</a></td>
226+
</tr>
227+
</table>
239228

240-
Big thanks to [@lufinkey](https://github.com/lufinkey) and all of the great work that he has done in the [react-native-spotify](https://github.com/lufinkey/react-native-spotify) repo which was the original source of inspiration & coding patterns for this package.
229+
<!-- markdownlint-enable -->
230+
<!-- prettier-ignore-end -->
231+
<!-- ALL-CONTRIBUTORS-LIST:END -->

0 commit comments

Comments
 (0)