Skip to content

Commit f2f4e2c

Browse files
authored
fix(player): 插队曲目切换后下一首曲目丢失 (#2118)
1 parent f2efc4e commit f2f4e2c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/utils/Player.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { decode as base642Buffer } from '@/utils/base64';
1414

1515
const PLAY_PAUSE_FADE_DURATION = 200;
1616

17+
const INDEX_IN_PLAY_NEXT = -1;
18+
1719
/**
1820
* @readonly
1921
* @enum {string}
@@ -255,8 +257,8 @@ export default class {
255257
const next = this._reversed ? this.current - 1 : this.current + 1;
256258

257259
if (this._playNextList.length > 0) {
258-
let trackID = this._playNextList.shift();
259-
return [trackID, this.current];
260+
let trackID = this._playNextList[0];
261+
return [trackID, INDEX_IN_PLAY_NEXT];
260262
}
261263

262264
// 循环模式开启,则重新播放当前模式下的相对的下一首
@@ -704,7 +706,12 @@ export default class {
704706
this._setPlaying(false);
705707
return false;
706708
}
707-
this.current = index;
709+
let next = index;
710+
if (index === INDEX_IN_PLAY_NEXT) {
711+
this._playNextList.shift();
712+
next = this.current;
713+
}
714+
this.current = next;
708715
this._replaceCurrentTrack(trackID);
709716
return true;
710717
}

0 commit comments

Comments
 (0)