Skip to content

Instantly share code, notes, and snippets.

@mager
Created February 10, 2012 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mager/1792009 to your computer and use it in GitHub Desktop.
Save mager/1792009 to your computer and use it in GitHub Desktop.
Spotify Apps API - Play/pause with an HTML element (JS)
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var player = models.player;
$('#play-me').click(function(){
player.playing = !(player.playing);
if (player.playing == true) {
$('#play-me').empty().append('Playing!');
} else {
$('#play-me').empty().append('Paused');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment