cordova-spotify
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "cordova-spotify", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Spotify SDK bindings for Cordova Applications", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -35,10 +35,12 @@ # Cordova Spotify SDK Plugin (Beta) | ||
All functions are asynchronous and return promises. The plugin automatically polyfills promise support through `es6-promise-plugin`. | ||
All functions are asynchronous and return promises (due to the way the Cordova <-> native code bridge works). The plugin automatically polyfills promise support through `es6-promise-plugin`. | ||
If the parameters have invalid values, an appropriate `Error` will be thrown immediately instead of returning a rejected promise. This is because invalid arguments are bugs and not runtime errors. | ||
If any of the function parameters have invalid values, an appropriate `Error` will be thrown immediately instead of returning a rejected promise. This is because invalid arguments are bugs and not runtime errors. | ||
### `getEventEmitter()` | ||
### `getEventEmitter(): Promise<EventEmitter>` | ||
Obtains an event emitter that relays the events fired by the native SDKs. The emitter will be created once and then returned on subsequent invocations. | ||
The emitter implementation comes from [eventemitter3](https://github.com/primus/eventemitter3). See their Github page for more information. | ||
The events emitted are the following: | ||
@@ -55,7 +57,7 @@ - `connectionmessage` | ||
### `getPosition()` | ||
### `getPosition(): Promise<number>` | ||
Obtains the players position in _milliseconds_. If no track is currently loaded, returns 0. | ||
### `play(trackUri: string, authOptions: object[, position: number])` | ||
### `play(trackUri: string, authOptions: object[, position: number]): Promise` | ||
@@ -74,11 +76,11 @@ Plays the track with the given Spotify URI. | ||
### `pause()` | ||
### `pause(): Promise` | ||
Pauses playback. If no track is loaded, returns normally. | ||
### `resume()` | ||
### `resume(): Promise` | ||
Resumes playback. If no track is loaded, the returned promise will be rejected with an error of type `not_playing`. | ||
### `seekTo(position: number)` | ||
### `seekTo(position: number): Promise` | ||
@@ -89,2 +91,2 @@ Sets the playback position to the given value. If no track is loaded, the returned promise will be rejected with an error of type `not_playing`. | ||
- `position`: The position (in _milliseconds_) to seek to. Must be > 0. | ||
- `position`: The position (in _milliseconds_) to seek to. Must be >= 0. |
@@ -59,2 +59,4 @@ import exec from './lib/exec-promise.js'; | ||
cordova.exec(event => { | ||
// First callback invocation confirms the emitter's registration | ||
// with the native code. The subsequent ones are actual events. | ||
if (!emitterRegistered) { | ||
@@ -66,4 +68,10 @@ emitterRegistered = true; | ||
} | ||
}, err => reject(err), 'SpotifyConnector', 'registerEventsListener', []); | ||
}, err => { | ||
// Make sure we can try again | ||
if (!emitterRegistered) { | ||
emitter = null; | ||
} | ||
reject(err); | ||
}, 'SpotifyConnector', 'registerEventsListener', []); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152975
227
89