@@ -70,6 +70,7 @@ export default {
7070 line: 0 ,
7171 },
7272 delayNextTimeout: null ,
73+ audioErrorTime: 0 ,
7374 // retryNum: 0,
7475 }
7576 },
@@ -174,8 +175,9 @@ export default {
174175 // console.log('code', this.audio.error.code)
175176 if (! this .musicInfo .songmid ) return
176177 console .log (' 出错' )
177- if (this .audio .error .code == 4 && this .retryNum < 3 ) { // 若音频URL无效则尝试刷新3次URL
178+ if (this .audio .error .code ! == 1 && this .retryNum < 3 ) { // 若音频URL无效则尝试刷新3次URL
178179 // console.log(this.retryNum)
180+ this .audioErrorTime = this .audio .currentTime // 记录出错的播放时间
179181 this .retryNum ++
180182 this .setUrl (this .list [this .playIndex ], true )
181183 return
@@ -203,6 +205,10 @@ export default {
203205 })
204206 this .audio .addEventListener (' loadeddata' , () => {
205207 this .maxPlayTime = this .audio .duration
208+ if (this .audioErrorTime ) {
209+ this .audio .currentTime = this .audioErrorTime
210+ this .audioErrorTime = 0
211+ }
206212 if (! this .targetSong .interval && this .listId != ' download' ) this .updateMusicInfo ({ index: this .playIndex , data: { interval: formatPlayTime2 (this .maxPlayTime ) } })
207213 this .status = ' 音乐加载中...'
208214 })
@@ -249,6 +255,7 @@ export default {
249255 this .checkDelayNextTimeout ()
250256 let targetSong = this .targetSong = this .list [this .playIndex ]
251257 this .retryNum = 0
258+ this .audioErrorTime = 0
252259
253260 if (this .listId == ' download' ) {
254261 if (! checkPath (targetSong .filePath ) || ! targetSong .isComplate || / \. ape$ / .test (targetSong .filePath )) {
@@ -369,12 +376,13 @@ export default {
369376 this .musicInfo .url = targetSong .typeUrl [type]
370377 this .status = ' 歌曲链接获取中...'
371378
372- this .getUrl ({ musicInfo: targetSong, type, isRefresh }).then (() => {
379+ return this .getUrl ({ musicInfo: targetSong, type, isRefresh }).then (() => {
373380 this .audio .src = this .musicInfo .url = targetSong .typeUrl [type]
374381 }).catch (err => {
375382 if (err .message == requestMsg .cancelRequest ) return
376383 this .status = err .message
377384 this .addDelayNextTimeout ()
385+ return Promise .reject (err)
378386 })
379387 },
380388 setImg (targetSong ) {
0 commit comments