mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 09:53:18 +00:00
Update Streamer class
This commit is contained in:
parent
1cfa62802f
commit
accff3fa60
@ -14,13 +14,15 @@ module.exports = class {
|
|||||||
if(!client.stations) return;
|
if(!client.stations) return;
|
||||||
|
|
||||||
client.stations.forEach(station => {
|
client.stations.forEach(station => {
|
||||||
|
const audioPlayer = createAudioPlayer();
|
||||||
|
this.map.set(station.name, audioPlayer);
|
||||||
this.play(station);
|
this.play(station);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
play(station) {
|
play(station) {
|
||||||
|
const audioPlayer = this.map.get(station.name);
|
||||||
const url = station.stream[station.stream.default];
|
const url = station.stream[station.stream.default];
|
||||||
const audioPlayer = createAudioPlayer();
|
|
||||||
const resource = createAudioResource(url);
|
const resource = createAudioResource(url);
|
||||||
audioPlayer.play(resource);
|
audioPlayer.play(resource);
|
||||||
resource.playStream
|
resource.playStream
|
||||||
@ -31,10 +33,12 @@ module.exports = class {
|
|||||||
.on("finish", () => {
|
.on("finish", () => {
|
||||||
this.logger('Streamer', station.name + " / " + "Finished");
|
this.logger('Streamer', station.name + " / " + "Finished");
|
||||||
this.map.delete(station.name);
|
this.map.delete(station.name);
|
||||||
|
this.play(station);
|
||||||
})
|
})
|
||||||
.on("error", error => {
|
.on("error", error => {
|
||||||
this.logger('Streamer', station.name + " / " + "Error");
|
this.logger('Streamer', station.name + " / " + "Error");
|
||||||
this.map.delete(station.name);
|
this.map.delete(station.name);
|
||||||
|
this.play(station);
|
||||||
});
|
});
|
||||||
return audioPlayer;
|
return audioPlayer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user