mirror of
https://github.com/YuzuZensai/NekoMelody.git
synced 2026-01-31 14:57:58 +00:00
🐛 fix: Queue not playing next song
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup ./src",
|
"build": "tsup ./src",
|
||||||
"example:test": "tsup ./src && tsx ./example/test.ts",
|
"example:discord": "tsup ./src && tsx ./example/discord.ts",
|
||||||
|
"example:speaker": "tsup ./src && tsx ./example/speaker.ts",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ export class Player {
|
|||||||
this.playerEvent.emit("play", information);
|
this.playerEvent.emit("play", information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public startCurrentStream() {
|
||||||
|
if (this._stream) {
|
||||||
|
this._stream.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public endCurrentStream() {
|
public endCurrentStream() {
|
||||||
if (this._stream) {
|
if (this._stream) {
|
||||||
this._stream.destroy();
|
this._stream.destroy();
|
||||||
|
|||||||
@@ -6,8 +6,19 @@ export class YtDlpProvider extends Provider {
|
|||||||
public ytDlpWrap = new YTDlpWrap();
|
public ytDlpWrap = new YTDlpWrap();
|
||||||
|
|
||||||
public canPlay(url: string) {
|
public canPlay(url: string) {
|
||||||
// TODO: Implement this
|
return this.checkUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private checkUrl(url: string) {
|
||||||
|
// https://www.youtube.com/watch?v=
|
||||||
|
// https://youtu.be/
|
||||||
|
if (
|
||||||
|
url.startsWith("https://www.youtube.com/watch?v=") ||
|
||||||
|
url.startsWith("https://youtu.be/")
|
||||||
|
)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getInformation(url: string) {
|
public async getInformation(url: string) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export class SeekableStream {
|
|||||||
private firstTick: boolean = true;
|
private firstTick: boolean = true;
|
||||||
private destroyed: boolean = false;
|
private destroyed: boolean = false;
|
||||||
private event: EventEmitter = new EventEmitter();
|
private event: EventEmitter = new EventEmitter();
|
||||||
|
private started: boolean = false;
|
||||||
|
|
||||||
private bytesReceived: number = 0;
|
private bytesReceived: number = 0;
|
||||||
private bytesRead: number = 0;
|
private bytesRead: number = 0;
|
||||||
@@ -54,6 +55,10 @@ export class SeekableStream {
|
|||||||
//if (seekTime !== 0) this.seek();
|
//if (seekTime !== 0) this.seek();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public start() {
|
||||||
|
this.started = true;
|
||||||
|
}
|
||||||
|
|
||||||
private async tick(seekTime?: number) {
|
private async tick(seekTime?: number) {
|
||||||
if (this.destroyed) {
|
if (this.destroyed) {
|
||||||
console.debug(
|
console.debug(
|
||||||
@@ -152,6 +157,8 @@ export class SeekableStream {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.started) return;
|
||||||
|
|
||||||
const isBufferSufficient =
|
const isBufferSufficient =
|
||||||
this.stream.readableLength >= this.bytesPerRequestLimit;
|
this.stream.readableLength >= this.bytesPerRequestLimit;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user