My Javascript/jQuery function is only running once and only the bottom part of the function is working. I can flip the order and then the other piece will work. What am I missing (using the Buzz audio API for the play and pause methods)?
var $playFromPlayerBar = $('.main-controls .play-pause');
var togglePlayFromPlayerBar = function(){
if (currentSoundFile.pause() && $playFromPlayerBar.click){
var $songNumberCell = getSongNumberCell(currentlyPlayingSongNumber);
$songNumberCell.html(pauseButtonTemplate);
$playFromPlayerBar.html(playerBarPauseButton);
currentSoundFile.play();
}
if (currentSoundFile.play() && $playFromPlayerBar.click){
var $songNumberCell = getSongNumberCell(currentlyPlayingSongNumber);
$songNumberCell.html(playButtonTemplate);
$playFromPlayerBar.html(playerBarPlayButton);
currentSoundFile.pause();
}
};
//load album when window loads
$(document).ready(function() {
$playFromPlayerBar.click(togglePlayFromPlayerBar);
});