From 64121c9e87fb438c94a64da17020068f12396e84 Mon Sep 17 00:00:00 2001 From: Colleen Date: Tue, 29 Sep 2015 15:46:53 -0700 Subject: [PATCH] =?UTF-8?q?33.=20jQuery:=20Buzz=20Library=20=E2=80=93?= =?UTF-8?q?=C2=A0Assignment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/album.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/album.js b/scripts/album.js index 4726982..c63aad4 100644 --- a/scripts/album.js +++ b/scripts/album.js @@ -174,6 +174,19 @@ var previousSong = function() { $lastSongNumberCell.html(lastSongNumber); }; +var togglePlayFromPlayerbar = function() { + var $currentlyPlayingCell = getSongNumberCell(currentlyPlayingSongNumber); + if (currentSoundFile.isPaused()) { + $currentlyPlayingCell.html(pauseButtonTemplate); + $(this).html(playerBarPauseButton); + currentSoundFile.play(); + } else if (currentSoundFile) { + $currentlyPlayingCell.html(playButtonTemplate); + $(this).html(playerBarPlayButton); + currentSoundFile.pause(); + } +}; + var playButtonTemplate = ''; var pauseButtonTemplate = ''; var playerBarPlayButton = ''; @@ -187,9 +200,11 @@ var currentVolume = 80; var $previousButton = $('.main-controls .previous'); var $nextButton = $('.main-controls .next'); +var $playPauseButton = $('.main-controls .play-pause'); $(document).ready(function() { setCurrentAlbum(albumPicasso); $previousButton.click(previousSong); $nextButton.click(nextSong); + $playPauseButton.click(togglePlayFromPlayerbar); }); \ No newline at end of file