fix(Queue): fix jump
This commit is contained in:
parent
731e30967c
commit
2344265fda
1 changed files with 6 additions and 1 deletions
|
@ -493,9 +493,14 @@ class Queue<T = unknown> {
|
||||||
*/
|
*/
|
||||||
jump(track: Track | number): void {
|
jump(track: Track | number): void {
|
||||||
if (this.#watchDestroyed()) return;
|
if (this.#watchDestroyed()) return;
|
||||||
|
// remove the track if exists
|
||||||
const foundTrack = this.remove(track);
|
const foundTrack = this.remove(track);
|
||||||
if (!foundTrack) throw new PlayerError("Track not found", ErrorStatusCode.TRACK_NOT_FOUND);
|
if (!foundTrack) throw new PlayerError("Track not found", ErrorStatusCode.TRACK_NOT_FOUND);
|
||||||
this.tracks.splice(0, 0, foundTrack);
|
// since we removed the existing track from the queue,
|
||||||
|
// we now have to place that to position 1
|
||||||
|
// because we want to jump to that track
|
||||||
|
// this will skip current track and play the next one which will be the foundTrack
|
||||||
|
this.tracks.splice(1, 0, foundTrack);
|
||||||
|
|
||||||
return void this.skip();
|
return void this.skip();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue