From accff3fa6059edb465a005019a4ef36be31698b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 11 Sep 2021 22:35:06 +0300 Subject: [PATCH] Update Streamer class --- src/client/classes/Streamer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index 437a479..5350e0a 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -14,13 +14,15 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { + const audioPlayer = createAudioPlayer(); + this.map.set(station.name, audioPlayer); this.play(station); }); } play(station) { + const audioPlayer = this.map.get(station.name); const url = station.stream[station.stream.default]; - const audioPlayer = createAudioPlayer(); const resource = createAudioResource(url); audioPlayer.play(resource); resource.playStream @@ -31,10 +33,12 @@ module.exports = class { .on("finish", () => { this.logger('Streamer', station.name + " / " + "Finished"); this.map.delete(station.name); + this.play(station); }) .on("error", error => { this.logger('Streamer', station.name + " / " + "Error"); this.map.delete(station.name); + this.play(station); }); return audioPlayer; }