diff --git a/public/js/music.js b/public/js/music.js index 535069e..9c72b9c 100755 --- a/public/js/music.js +++ b/public/js/music.js @@ -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(); + } }