aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoCoreDuo <[email protected]>2024-06-13 07:25:35 +0200
committerGitHub <[email protected]>2024-06-13 00:25:35 -0500
commit29b61cc0b6363b3e07f17bd7d41400d20827f959 (patch)
tree999a5aafd8710ea64bd0d952021a3c34715ddd35 /src
parentcc0cf8379ca2b78b1f5b8358e68bbbd32b3571e9 (diff)
downloadmuse-29b61cc0b6363b3e07f17bd7d41400d20827f959.tar.xz
muse-29b61cc0b6363b3e07f17bd7d41400d20827f959.zip
Stop audioplayer properly (#1032)
Diffstat (limited to 'src')
-rw-r--r--src/services/player.ts15
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;
});