Skip to content

DorkNstein/Cordova-spotify-plugin-ios-android

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

N|Solid

Cordova Spotify Plugin

I modified this plugin to match my requirements of native login authentications for android and ios. 😏

Installation

To communicate with Spotify you need to register your application’s bundle id section in the Developer Portal. This value is used to authenticate your application against Spotify client.

You may install latest version from master

cordova plugin add https://github.com/jeweller1980stepanets/Cordova-spotify-plugin-ios-android

Removing the Plugin from project

cordova plugin rm cordova.plugin.spotify

Supported Platforms

  • Android
  • iOS

Platform specific

⚠️ for Android platform not implemented method setVolume() and event onVolumeChanged() It will be fixed when this methods will be in Spotify SDK

Using the plugin

You must have premium account from Deezer servise for playing music

After device is ready you must defined the main variable:

var Spotify = window.cordova.plugins.SpotifyPlugin;

👍 After this you may use all method in your code.

Methods

All methods returning promises, but you can also use standard callback functions.

Spotify.login(appId, redirectURL, mode, function(success) {...}, function(error) {...});
  • appId - your application id in Spotify
  • redirectURL - White-listed addresses to redirect to after authentication success OR failure
  • mode - The mode of debugging, if you use Xcode emulator its value should be "debug" else empty string
Spotify.auth(token,clientId);
  • token - spotify access token;
  • clientId - your application id in Spotify.
Spotify.play(value);
  • value - track id or album id or playlist id

Exemple:

Spotify.play("spotify:track:3qRNQHagYiiDLdWMSOkPGG"); Spotify.play("spotify:album:75Sgdm3seM5KXkEd46vaDb"); Spotify.play("spotify:user:spotify:playlist:2yLXxKhhziG2xzy7eyD4TD");

Spotify.pause();
Spotify.next();
Spotify.prev();
Spotify.logout();
Spotify.seek(position);

position - value between 0...100 %

Spotify.seekTo(position);

position - value in seconds

Spotify.setVolume(val1,val2);

val1,val2 - the volume for the left and right channel (between 0...100%)

Events

Spotify.Events.onMetadataChanged = function(args){};

args[0] - current track; args[1] - artist name; args[2] - album name; args[3] - track duration.

Spotify.Events.onPlayerPlay = function(arg){};

arg - name of event (string)

Spotify.Events.onPrev = function(args){};

args[0] - action name;

Spotify.Events.onNext = function(args){};

args[0] - action name;

Spotify.Events.onPause = function(args){};

args[0] - action name;

Spotify.Events.onPlay = function(args){};

args[0] - action name;

Spotify.Events.onAudioFlush = function(args){};

args[0] - position (ms);

Spotify.Events.onTrackChanged = function(args){};

args[0] - action name;

Spotify.Events.onPosition = function(args){};

args[0] - position (ms);

Spotify.Events.onVolumeChanged = function(args){};

args[0] - volume betwen 0.0 ....1.0

Spotify.Events.onPlayError = function(error){};

error[0] - error message

Authors

  • Aleksey Stepanets

N|Solid

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Objective-C 86.8%
  • Java 10.6%
  • JavaScript 1.6%
  • Ruby 1.0%