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