From 7dc2d033008bd6724cfb60c989e256b9c3076bff Mon Sep 17 00:00:00 2001 From: JoslynT Date: Mon, 16 Sep 2019 23:18:50 -0700 Subject: [PATCH 1/4] added toinfo --- scripts/album-info.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/album-info.js b/scripts/album-info.js index e69de29b..573992d4 100644 --- a/scripts/album-info.js +++ b/scripts/album-info.js @@ -0,0 +1,6 @@ +{ + $('#album-title').text(album.title); + $('img#album-cover-art').attr('src', album.albumArtUrl); + $('.artist').text(album.artist); + $('#release-info').text(album.releaseInfo); +} From 7f1ee4490796b3a6bc18e07e640e5fd1bba37d1e Mon Sep 17 00:00:00 2001 From: JoslynT Date: Tue, 17 Sep 2019 00:37:56 -0700 Subject: [PATCH 2/4] song-list --- scripts/song-list.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/song-list.js b/scripts/song-list.js index e69de29b..47e2e619 100644 --- a/scripts/song-list.js +++ b/scripts/song-list.js @@ -0,0 +1,23 @@ +{ + album.songs.forEach( (song, index) => { + song.element = $(` + + + + + ${song.title} + ${song.duration} + + `); + + song.element.on('click', event => { + player.playPause(song); + }); + + $('#song-list').append(song.element); + }); +} From a9753a9876865cd7380bcb3131658191f46569c9 Mon Sep 17 00:00:00 2001 From: JoslynT Date: Tue, 17 Sep 2019 15:29:07 -0700 Subject: [PATCH 3/4] next and previous --- scripts/player-bar.js | 30 ++++++++++++++++++++++++++++++ scripts/song-list.js | 1 + 2 files changed, 31 insertions(+) diff --git a/scripts/player-bar.js b/scripts/player-bar.js index e69de29b..56223141 100644 --- a/scripts/player-bar.js +++ b/scripts/player-bar.js @@ -0,0 +1,30 @@ +{ + $('button#play-pause').on('click', function() { + player.playPause(); + $(this).attr('playState', player.playState); + }); + + $('button#next').on('click', function() { + if (player.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); + }); + + $('button#previous').click( function () { + if (player.playState !== 'playing') { return; } + + const currentSongIndex = album.songs.indexOf(player.currentlyPlaying); + const previousSongIndex = currentSongIndex - 1; + if (previousSongIndex < 0) { return; } + + const previousSong = album.songs[previousSongIndex]; + player.playPause(previousSong); + + }); + +} diff --git a/scripts/song-list.js b/scripts/song-list.js index 47e2e619..cd4fdbf0 100644 --- a/scripts/song-list.js +++ b/scripts/song-list.js @@ -16,6 +16,7 @@ song.element.on('click', event => { player.playPause(song); + $('button#play-pause').attr('playState', player.playState); }); $('#song-list').append(song.element); From 9f5e3f17dc9ee7ec13b252575e4881d175f30792 Mon Sep 17 00:00:00 2001 From: JoslynT Date: Tue, 17 Sep 2019 15:34:34 -0700 Subject: [PATCH 4/4] player-bar --- scripts/player-bar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/player-bar.js b/scripts/player-bar.js index 56223141..b667363b 100644 --- a/scripts/player-bar.js +++ b/scripts/player-bar.js @@ -24,7 +24,7 @@ if (nextSongIndex >= album.songs.length) { return; } const previousSong = album.songs[previousSongIndex]; player.playPause(previousSong); - + }); }