feat: seek
This commit is contained in:
parent
31be4aa76d
commit
da0b85077b
1 changed files with 14 additions and 0 deletions
|
@ -254,6 +254,20 @@ class Queue<T = unknown> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async seek(position: number) {
|
||||||
|
if (!this.playing || !this.current) return false;
|
||||||
|
if (position < 1) position = 0;
|
||||||
|
if (position >= this.current.durationMS) return this.skip();
|
||||||
|
|
||||||
|
await this.play(this.current, {
|
||||||
|
immediate: true,
|
||||||
|
filtersUpdate: true, // to stop events
|
||||||
|
seek: position
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays previous track
|
* Plays previous track
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
|
|
Loading…
Reference in a new issue