emit audio resource
This commit is contained in:
parent
817bfdc9b5
commit
f0259b39ce
2 changed files with 8 additions and 8 deletions
|
@ -141,16 +141,17 @@ class Queue<T = unknown> {
|
||||||
|
|
||||||
this.player.emit("connectionCreate", this, this.connection);
|
this.player.emit("connectionCreate", this, this.connection);
|
||||||
|
|
||||||
this.connection.on("start", () => {
|
this.connection.on("start", (resource) => {
|
||||||
this.playing = true;
|
this.playing = true;
|
||||||
if (!this._filtersUpdate) this.player.emit("trackStart", this, this.current);
|
if (!this._filtersUpdate) this.player.emit("trackStart", this, resource.metadata);
|
||||||
this._filtersUpdate = false;
|
this._filtersUpdate = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connection.on("finish", async () => {
|
this.connection.on("finish", async (resource) => {
|
||||||
this.playing = false;
|
this.playing = false;
|
||||||
if (this._filtersUpdate) return;
|
if (this._filtersUpdate) return;
|
||||||
this._streamTime = 0;
|
this._streamTime = 0;
|
||||||
|
this.previousTracks.push(resource.metadata);
|
||||||
|
|
||||||
if (!this.tracks.length && this.repeatMode === QueueRepeatMode.OFF) {
|
if (!this.tracks.length && this.repeatMode === QueueRepeatMode.OFF) {
|
||||||
if (this.options.leaveOnEnd) this.destroy();
|
if (this.options.leaveOnEnd) this.destroy();
|
||||||
|
@ -405,7 +406,6 @@ class Queue<T = unknown> {
|
||||||
|
|
||||||
if (!options.filtersUpdate) {
|
if (!options.filtersUpdate) {
|
||||||
this.previousTracks = this.previousTracks.filter((x) => x._trackID !== track._trackID);
|
this.previousTracks = this.previousTracks.filter((x) => x._trackID !== track._trackID);
|
||||||
this.previousTracks.push(track);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let stream;
|
let stream;
|
||||||
|
|
|
@ -20,8 +20,8 @@ import { Util } from "../utils/Util";
|
||||||
export interface VoiceEvents {
|
export interface VoiceEvents {
|
||||||
error: (error: AudioPlayerError) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
error: (error: AudioPlayerError) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
debug: (message: string) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
debug: (message: string) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
start: () => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
start: (resource: AudioResource<Track>) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
finish: () => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
finish: (resource: AudioResource<Track>) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
}
|
}
|
||||||
|
|
||||||
class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
||||||
|
@ -89,11 +89,11 @@ class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
||||||
this.audioPlayer.on("stateChange", (oldState, newState) => {
|
this.audioPlayer.on("stateChange", (oldState, newState) => {
|
||||||
if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
|
if (newState.status === AudioPlayerStatus.Idle && oldState.status !== AudioPlayerStatus.Idle) {
|
||||||
if (!this.paused) {
|
if (!this.paused) {
|
||||||
|
void this.emit("finish", this.audioResource);
|
||||||
this.audioResource = null;
|
this.audioResource = null;
|
||||||
void this.emit("finish");
|
|
||||||
}
|
}
|
||||||
} else if (newState.status === AudioPlayerStatus.Playing) {
|
} else if (newState.status === AudioPlayerStatus.Playing) {
|
||||||
if (!this.paused) void this.emit("start");
|
if (!this.paused) void this.emit("start", this.audioResource);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue