From 7d479b4c5fdd69b5742e59a758f8f0090bf9ead1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 23:19:49 +0300 Subject: [PATCH] Update Streamer class --- src/client/classes/Streamer.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 8622264..ee8df57 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -29,7 +29,7 @@ module.exports = class { let streamers = this.map.keys(); streamers.forEach(streamer => { if(client.stations.findIndex(station => station.name == streamer)) return; - this.map.delete(streamer); + this.stop(streamer); }); } @@ -56,6 +56,12 @@ module.exports = class { return audioPlayer; } + stop(station){ + let audioPlayer = this.map.get(station.name); + audioPlayer?.stop(); + this.map.delete(station.name); + } + listen(station) { let audioPlayer = this.map.get(station.name); if(!audioPlayer){ @@ -68,9 +74,7 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { - let streamer = this.map.get(station.name); - streamer?.stop(); - this.map.delete(station.name); + this.stop(station); }); } };