This plugin included all main functions of audio player for Spotify servise 😏
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
cordova plugin rm cordova.plugin.spotify
- Android
- iOS
setVolume()
and event onVolumeChanged()
It will be fixed when this methods will be in Spotify SDK
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.
All methods returning promises, but you can also use standard callback functions.
Spotify.login(appId, redirectURL, mode);
- 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%)
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
- Aleksey Stepanets