jQuery Spotify Add to Playlist Plugin
Simple plugin to allow a user to add a track to a Spotify playlist. If the playlist doesn't exist, it gets created and if it already exists, the song just gets added to it.
Demo: http://ewillhite.github.io/jquery-spotify-add-playlist/
Usage
- Install using bower or make sure you install dependency (jQuery >=1.4)
- Create a Spotify application here: https://developer.spotify.com/
- Add a redirect uri to your Spotify app that is [yourwebsite.com]/spotify-callback
- Include plugin after jQuery
- Invoke the plugin:
// Click function just used as an example $('button').click(function(e) { // Set Track ID var track = $(this).data('track'); $(this).spotify_add_to_playlist({ // Playlist Name - can be whatever you like playlist_name:'My Funky Playlist', // Client ID from your Spotify application in step 2 client_id:'', // Track Spotify ID track: track }); e.preventDefault(); });
Credits
This plugin based on development done for Essential Worship at Centresource. It was also inspired heavily by the good work of https://github.com/possan/playlistcreator-example