@@ -354,13 +354,13 @@ var player = (function () {
354354 //
355355 _self . currentSongIndex = parseInt ( this . getAttribute ( 'data-index' ) , 10 ) ;
356356
357- changeSong ( _self . currentSongIndex ) ;
357+ playSong ( _self . currentSongIndex ) ;
358358 } ) ;
359359 } ) ;
360360
361361 }
362362
363- function changeSong ( index ) {
363+ function playSong ( index ) {
364364
365365 _self . currentSongIndex = index ;
366366
@@ -375,18 +375,27 @@ var player = (function () {
375375
376376 function nextSong ( ) {
377377
378- if ( _self . config . loop === 'none' ) return ;
379-
378+ // No mater if playlist should replay from start or not, if `loop` is `one`,
379+ // keep playing the same song. `currentSongIndex` does not change.
380380 if ( _self . config . loop === 'one' ) {
381- changeSong ( _self . currentSongIndex ) ;
381+ playSong ( _self . currentSongIndex ) ;
382382 return ;
383383 }
384384
385+ // If we are at the last song and `loop` is `none`, DO NOT start over playing at
386+ // the first item in the playlist.
387+ if ( _self . currentSongIndex === _self . config . songs . length - 1 && _self . config . loop === 'none' ) {
388+ return ;
389+ }
390+
391+
392+ // If we got to this point, either play the next song or start over again
393+ // from the first item in the playlist.
385394 var songIndex = ( _self . currentSongIndex < _self . config . songs . length - 1 )
386395 ? songIndex = _self . currentSongIndex + 1
387396 : songIndex = 0 ;
388397
389- changeSong ( songIndex ) ;
398+ playSong ( songIndex ) ;
390399 }
391400
392401 function bindEventHandlers ( ) {
0 commit comments