Created
February 10, 2012 18:22
-
-
Save mager/1791443 to your computer and use it in GitHub Desktop.
Spotify Apps API - Get the currently playing track (JS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Instantiate the global sp object; include models & views */ | |
var sp = getSpotifyApi(1); | |
var models = sp.require("sp://import/scripts/api/models"); | |
// Get the track that is currently playing | |
var currentTrack = models.player.track; | |
// If nothing currently playing | |
if (currentTrack == null) { | |
$('#now-playing').append('No track currently playing'); | |
} else { | |
var track = currentTrack; | |
var artist = track.artists[0].name; | |
$('#now-playing').append("Now playing: " + track, artist); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment