diff --git a/index.html b/index.html index 83c9da28..6f8647f1 100644 --- a/index.html +++ b/index.html @@ -25,8 +25,8 @@

-

-
+

Pablo Picaso

+
1909 Spanish Records
@@ -36,11 +36,11 @@

- + - +
@@ -71,7 +71,7 @@

- +
diff --git a/scripts/album-info.js b/scripts/album-info.js index e69de29b..b2833a23 100644 --- a/scripts/album-info.js +++ b/scripts/album-info.js @@ -0,0 +1,4 @@ +{ +$('#album-title').text(album.title); +$('img#album-cover-art').attr('src', album.albumArtUrl); +} diff --git a/scripts/player-bar.js b/scripts/player-bar.js index e69de29b..e2e1a832 100644 --- a/scripts/player-bar.js +++ b/scripts/player-bar.js @@ -0,0 +1,36 @@ +{ + $('button#play-pause').on('click', function() { + player.playPause(); + $('button#play-pauuse').attr('playState', player.playState); + }); + + $('button#next').on('click', function(){ + player.playPause(); + $(this).attr('playState', player.playState); + ) + }); + + $('button#next').on('click', function(){ + if(play.playState !== 'playing') {return;} + }); + const currentSongIndex = album.songs.indexOf(player.currentlyPlaying); + const nextSongIndex = currentSongIndex + 1; + if(nextSongIndex >= album.songs.length) {return;} + + const nextSong = album.songs[nextSongIndex]; + player.playPause(nextSong); + }); + + $('#time-control input').on('input', function (event) { + player.skipTo(event.target.value); + }); + + setInterval( () => { + if (player.playState !== 'playing') { return; } + const currentTime = player.getTime(); + const duration = player.getDuration(); + const percent = (currentTime / duration) * 100; + $('#time-control .current-time').text( currentTime ); + $('#time-control input').val(percent); + }, 1000); +} diff --git a/scripts/song-list.js b/scripts/song-list.js index e69de29b..bb13455f 100644 --- a/scripts/song-list.js +++ b/scripts/song-list.js @@ -0,0 +1,25 @@ +{ + album.songs.forEach( (song, index) => { + song.element = $(` + + + + + ${song.title} + ${song.duration} + + `); + + song.element.on('click', event => { + player.playPause(song); + $('button#play-pause').attr('playState',player.playState); + }); + + + $('#song-list').append(song.element); + }); + }