A Pen by Jason Stallings on CodePen.
Created
July 29, 2022 01:20
-
-
Save quarterback/7cc2983b8fa882fbbfc5d391229fe35c to your computer and use it in GitHub Desktop.
Now playing - Last.fm
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
Only displays when you're currently listening to music.<br> | |
Update "username" in JavaScript with your Last.fm username. | |
<div id="last"> | |
<p><a href="http://www.last.fm/user/comic_coder/now"><img id="artwork" src=""></a></p><div id="track"></div> | |
</div> |
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
//Replace with your Last.fm username. | |
username="comic_coder"; | |
$("#last a").attr("href", "http://www.last.fm/user/" + username + "/now"); | |
$.get( "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=" + username + "&api_key=1f633977acf0e2d0630ec11dbc350d3e&format=json", function( data ) | |
{ | |
if (typeof data.recenttracks.track[0]["@attr"] != "undefined") | |
{ | |
artist=data.recenttracks.track[0].artist["#text"]; | |
track=data.recenttracks.track[0].name; | |
album=data.recenttracks.track[0].album["#text"]; | |
artwork=data.recenttracks.track[0].image[1]["#text"]; | |
$("#artwork").attr("src", artwork); | |
$("#track").html(track + "<br>" + artist + "<br><br>" + album); | |
$("#last").fadeIn("slow"); | |
} | |
}); |
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
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
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
#last | |
{ | |
display:none; | |
position:fixed; | |
bottom:0px; | |
right:0px; | |
width:200px; | |
} | |
#last img | |
{ | |
padding-right:5px; | |
} | |
#last p | |
{ | |
float:left; | |
} | |
#last div | |
{ | |
margin:16px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment