Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
cordova-spotify
Advanced tools
An Apache Cordova plugin providing access to the Spotify SDK for iOS and Android.
This plugin provides a very simple and atomic layer over playback functionality of the Spotify SDK. It allows you to play Spotify tracks via their URI. Metadata and authentication functionality has deliberately been left out in favor of the Web API and our Spotify OAuth 2 plugin cordova-spotify-oauth.
cordova plugin add cordova-spotify
Note: Make sure your installation path doesn't contain any spaces.
Pull requests are very welcome! Please use the gitmoji style for commit messages.
The plugin has an extremely simple API that is focused just on playback. It consists of six functions clobbered onto cordova.plugins.spotify
. In the following, treat all paths relative to that. The plugin handles all internal state and SDK initialization aspects automatically and hides these aspects from the developer.
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 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(): 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. See their Github page for more information.
The events emitted are the following:
connectionmessage
loggedin
loggedout
loginfailed
playbackerror
playbackevent
temporaryerror
In the case of loginfailed
, playbackevent
and playbackerror
, the event contains a payload that describes what happened exactly. The payload is simply the name of the discriminant of the enum in the native SDK without the prefix (usually kSp
or kSpError
). See the offical documentation here and here for all variants.
getPosition(): Promise<number>
Obtains the players position in milliseconds. If no track is currently loaded, returns 0.
play(trackUri: string, authOptions: object[, position: number]): Promise
Plays the track with the given Spotify URI.
trackUri
: The Spotify URI of the track to play. E.g. spotify:track:6nTiIhLmQ3FWhvrGafw2z
. May not be null.authOptions
: An object containing two keys:
token: string
: A valid Spotify access token with the streaming
scope. May not be null. You can use the cordova-spotify-oauth plugin for authentication.clientId: string
: Your application's client ID as obtained from https://developer.spotify.com. May not be null.position
: Optional. The position (in milliseconds) to start playing the track from. Must be >= 0.token
and clientId
may change freely during runtime. The plugin will handle the required login / logout processes automatically when a new track is played.
pause(): Promise
Pauses playback. If no track is loaded, returns normally.
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): Promise
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.FAQs
Spotify SDK bindings for Cordova Applications
The npm package cordova-spotify receives a total of 13 weekly downloads. As such, cordova-spotify popularity was classified as not popular.
We found that cordova-spotify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.