@@ -91,6 +91,7 @@ class APlayer {
9191 this . list = new List ( this ) ;
9292
9393 this . initAudio ( ) ;
94+ this . bindEvents ( ) ;
9495 if ( this . options . order === 'random' ) {
9596 this . list . switch ( this . randomOrder [ 0 ] ) ;
9697 }
@@ -116,6 +117,10 @@ class APlayer {
116117 } ) ;
117118 }
118119
120+ this . volume ( this . storage . get ( 'volume' ) , true ) ;
121+ }
122+
123+ bindEvents ( ) {
119124 this . on ( 'play' , ( ) => {
120125 if ( this . paused ) {
121126 this . setUIPlaying ( ) ;
@@ -153,10 +158,11 @@ class APlayer {
153158 } ) ;
154159
155160 // audio download error: an error occurs
161+ let skipTime ;
156162 this . on ( 'error' , ( ) => {
157163 if ( this . list . audios . length ) {
158164 this . notice ( 'An audio error has occurred, player will skip forward in 2 seconds.' ) ;
159- setTimeout ( ( ) => {
165+ skipTime = setTimeout ( ( ) => {
160166 this . skipForward ( ) ;
161167 if ( ! this . paused ) {
162168 this . play ( ) ;
@@ -167,6 +173,9 @@ class APlayer {
167173 this . notice ( 'An audio error has occurred.' ) ;
168174 }
169175 } ) ;
176+ this . events . on ( 'listswitch' , ( ) => {
177+ skipTime && clearTimeout ( skipTime ) ;
178+ } ) ;
170179
171180 // multiple audio play
172181 this . on ( 'ended' , ( ) => {
@@ -201,8 +210,6 @@ class APlayer {
201210 this . play ( ) ;
202211 }
203212 } ) ;
204-
205- this . volume ( this . storage . get ( 'volume' ) , true ) ;
206213 }
207214
208215 setAudio ( audio ) {
@@ -434,7 +441,9 @@ class APlayer {
434441 if ( this . noticeTime ) {
435442 clearTimeout ( this . noticeTime ) ;
436443 }
437- this . events . trigger ( 'noticeshow' , text ) ;
444+ this . events . trigger ( 'noticeshow' , {
445+ text : text ,
446+ } ) ;
438447 if ( time ) {
439448 this . noticeTime = setTimeout ( ( ) => {
440449 this . template . notice . style . opacity = 0 ;
0 commit comments