From 3ed49f88ab3fd2ed843352d442fa9ea27d159b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 12 Sep 2021 17:39:23 +0300 Subject: [PATCH] Update Streamer class --- src/client/classes/Streamer.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.js index a796e76..d22cb49 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.js @@ -6,8 +6,7 @@ const { module.exports = class { constructor() { this.map = new Map(); - this.mode = "auto"; - this.stations = null; + this.mode = null; this.logger = require("../funcs/logger.js"); } @@ -17,6 +16,7 @@ module.exports = class { switch(client.config.streamerMode){ case "manual": this.mode = "manual"; + break; default: this.mode = "auto"; } @@ -25,11 +25,6 @@ module.exports = class { if(!client.stations) return; client.stations.forEach(station => { - let audioPlayer = this.map.get(station.name); - if(!audioPlayer) { - audioPlayer = createAudioPlayer(); - this.map.set(station.name, audioPlayer); - } this.play(station); }); } @@ -46,7 +41,11 @@ module.exports = class { } play(station) { - const audioPlayer = this.map.get(station.name); + let audioPlayer = this.map.get(station.name); + if(!audioPlayer) { + audioPlayer = createAudioPlayer(); + this.map.set(station.name, audioPlayer); + } const url = station.stream[station.stream.default]; const resource = createAudioResource(url); audioPlayer.play(resource);