mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-10 06:20:20 +00:00
Update Streamer class
This commit is contained in:
parent
752bd07c5d
commit
3ed49f88ab
@ -6,8 +6,7 @@ const {
|
|||||||
module.exports = class {
|
module.exports = class {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.map = new Map();
|
this.map = new Map();
|
||||||
this.mode = "auto";
|
this.mode = null;
|
||||||
this.stations = null;
|
|
||||||
this.logger = require("../funcs/logger.js");
|
this.logger = require("../funcs/logger.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,6 +16,7 @@ module.exports = class {
|
|||||||
switch(client.config.streamerMode){
|
switch(client.config.streamerMode){
|
||||||
case "manual":
|
case "manual":
|
||||||
this.mode = "manual";
|
this.mode = "manual";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
this.mode = "auto";
|
this.mode = "auto";
|
||||||
}
|
}
|
||||||
@ -25,11 +25,6 @@ module.exports = class {
|
|||||||
if(!client.stations) return;
|
if(!client.stations) return;
|
||||||
|
|
||||||
client.stations.forEach(station => {
|
client.stations.forEach(station => {
|
||||||
let audioPlayer = this.map.get(station.name);
|
|
||||||
if(!audioPlayer) {
|
|
||||||
audioPlayer = createAudioPlayer();
|
|
||||||
this.map.set(station.name, audioPlayer);
|
|
||||||
}
|
|
||||||
this.play(station);
|
this.play(station);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -46,7 +41,11 @@ module.exports = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
play(station) {
|
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 url = station.stream[station.stream.default];
|
||||||
const resource = createAudioResource(url);
|
const resource = createAudioResource(url);
|
||||||
audioPlayer.play(resource);
|
audioPlayer.play(resource);
|
||||||
|
Loading…
Reference in New Issue
Block a user