Fixed album changing process

This commit is contained in:
gballan1 2016-11-28 23:51:33 -05:00
parent 78eb16d137
commit 11e0377b36

View File

@ -75,7 +75,7 @@ function getAlbumSongs(albumElem) {
playlist.append(songElem);
}
changeSelectedTrack(playlist.find('.selected'));
changeAudioSources(playlist.find('.selected'), false);
});
}
@ -89,14 +89,18 @@ function changeSelectedTrack(trackElem) {
newSelected.addClass('selected');
// now change the audio sources
changeAudioSources(trackElem);
changeAudioSources(trackElem, true);
}
}
function changeAudioSources(trackElem) {
function changeAudioSources(trackElem, autoplay) {
trackElem = $(trackElem);
var playerSources = $('#music-player source');
if (autoplay === null) {
autoplay = false;
}
// retrieve audio file path from selected element
var audioFilePath = trackElem.data('path');
@ -116,6 +120,9 @@ function changeAudioSources(trackElem) {
// reload music player
player.load();
// start playing new song
player.play();
if (autoplay) {
// start playing new song
player.play();
}
}