diff --git a/static/musik.css b/static/musik.css index 14a570b..d7a521b 100644 --- a/static/musik.css +++ b/static/musik.css @@ -41,8 +41,11 @@ img { #albumCover { padding-right: 1em; + padding-left: 1em; } #playerControls { text-align: center; + padding-right: 0.5em; + padding-bottom: 0.5em; } diff --git a/static/musik.js b/static/musik.js index e2f3bfa..4b43191 100644 --- a/static/musik.js +++ b/static/musik.js @@ -1,17 +1,20 @@ var httpRequest function load() { + // track has ended document.getElementById('player').addEventListener('ended', function() { - if (!document.getElementById('shuffle').checked) { return; } - httpRequest = new XMLHttpRequest(); - httpRequest.onreadystatechange = function() { - if (httpRequest.readyState !== XMLHttpRequest.DONE) { return; } - if (httpRequest.status !== 200) { return; } - let track = httpRequest.responseText; - change_track(track); + // shuffle + if (document.getElementById('shuffle').checked) { + httpRequest = new XMLHttpRequest(); + httpRequest.onreadystatechange = function() { + if (httpRequest.readyState !== XMLHttpRequest.DONE) { return; } + if (httpRequest.status !== 200) { return; } + let track = httpRequest.responseText; + change_track(track); + } + httpRequest.open('GET', '/musik/get_shuffle', true); + httpRequest.send(); } - httpRequest.open('GET', '/musik/get_shuffle', true); - httpRequest.send(); }); } @@ -37,6 +40,10 @@ function change_track(track) { player.load(); player.play(); document.getElementById('nowPlaying').innerHTML = track; + + let cd = document.getElementById('currentDirectory').innerText; + let art = document.getElementById('albumCover'); + art.firstChild.src = '/musik/album_cover' + cd + 'folder.jpg'; } function get_dir(item) {