From cbde524e19d38dbcbda8f5d5d134c07287320511 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Sat, 17 Aug 2024 18:29:57 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Queue=20skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/player/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/player/index.ts b/src/player/index.ts index 4b069ed..baf4725 100644 --- a/src/player/index.ts +++ b/src/player/index.ts @@ -123,6 +123,17 @@ export class Player { await this.play(this._stream.referenceUrl, time); } + public async skip() { + if (this.queue.length === 0) { + throw new Error("No song in queue"); + } + + const next = this.queue.shift(); + if (next) { + this._createStream(next, next.url, 0); + } + } + public getCurrentSampleRate() { return this._stream?.information.bitrate || 0; }