File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 33 */
44player . init ( {
55 loop : 'all' , // 'none', 'one', 'all'. Default: 'none'.
6+ volume : 50 , // 1 to 100.
7+ autoplay : false ,
68 songs : [
79 //{url: 'https://upload.wikimedia.org/wikipedia/en/4/45/ACDC_-_Back_In_Black-sample', name: 'Black in Black'},
810 { url : 'songs/one' , name : 'Amberdawn' } ,
Original file line number Diff line number Diff line change @@ -105,10 +105,16 @@ var player = (function () {
105105 //
106106 var sourceOgg = createNode ( 'source' ) ;
107107 sourceOgg . setAttribute ( 'id' , 'oggPath' ) ;
108- sourceMp3 . setAttribute ( 'type' , 'audio/ogg' ) ;
108+ sourceOgg . setAttribute ( 'type' , 'audio/ogg' ) ;
109109 sourceOgg . setAttribute ( 'src' , arrSongs [ index ] . url + '.ogg' ) ;
110110 _self . dnAudio . appendChild ( sourceOgg ) ;
111111
112+ // The audio tag iteself is built only once. When the current song
113+ // changes, only its audio url changes, but we do not recreate the audio
114+ // tag. That means autoplay only works on page load and it doesn't interfere
115+ // with changing songs through the playlist later.
116+ _self . dnAudio . autoplay = _self . config . autoplay ;
117+
112118 _self . currentSongIndex = parseInt ( index , 10 ) ;
113119 } ;
114120
@@ -551,6 +557,7 @@ var player = (function () {
551557
552558 config . volume = config . volume || 80 ;
553559 config . volume = config . volume / 100 ;
560+ config . autoplay = config . autoplay || false ;
554561
555562 _self . config = config ;
556563 }
You can’t perform that action at this time.
0 commit comments