Update Streamer class

This commit is contained in:
Christer Warén 2021-09-12 17:09:32 +03:00
parent 3029a8a653
commit 892c5f9902

View File

@ -6,21 +6,33 @@ const {
module.exports = class { module.exports = class {
constructor() { constructor() {
this.map = new Map(); this.map = new Map();
this.mode = "auto";
this.stations = null; this.stations = null;
this.logger = require("../funcs/logger.js"); this.logger = require("../funcs/logger.js");
} }
init(client){ init(client){
if(!client.stations) return; if(!client.config.streamerMode) return;
client.stations.forEach(station => { switch(client.config.streamerMode){
let audioPlayer = this.map.get(station.name); case "manual":
if(!audioPlayer) { this.mode = "manual";
audioPlayer = createAudioPlayer(); default:
this.map.set(station.name, audioPlayer); this.mode = "auto";
} }
this.play(station);
}); if(this.mode == "auto"){
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);
});
}
} }
refresh(client){ refresh(client){