diff options
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/player.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/services/player.ts b/src/services/player.ts index 2ec177c..0da80a4 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -126,7 +126,7 @@ export default class { this.loopCurrentSong = false; this.voiceConnection.destroy(); - this.audioPlayer?.stop(); + this.audioPlayer?.stop(true); this.voiceConnection = null; this.audioPlayer = null; @@ -280,7 +280,7 @@ export default class { if (this.getCurrent() && this.status !== STATUS.PAUSED) { await this.play(); } else { - this.audioPlayer?.stop(); + this.audioPlayer?.stop(true); this.status = STATUS.IDLE; const settings = await getGuildSettings(this.guildId); @@ -429,6 +429,12 @@ export default class { } private async getStream(song: QueuedSong, options: {seek?: number; to?: number} = {}): Promise<Readable> { + if (this.status === STATUS.PLAYING) { + this.audioPlayer?.stop(); + } else if (this.status === STATUS.PAUSED) { + this.audioPlayer?.stop(true); + } + if (song.source === MediaSource.HLS) { return this.createReadStream({url: song.url, cacheKey: song.url}); } @@ -619,7 +625,10 @@ export default class { stream.pipe(capacitor); returnedStream.on('close', () => { - stream.kill('SIGKILL'); + if (!options.cache) { + stream.kill('SIGKILL'); + } + hasReturnedStreamClosed = true; }); |
