Update Streamer class

This commit is contained in:
Christer Warén 2021-12-12 01:00:00 +02:00
parent 95a0bdfdd2
commit b4f2ece9bf

View File

@ -70,17 +70,6 @@ module.exports = class {
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);
resource.playStream
.on("readable", () => {
this.logger('Streamer', station.name + " / " + "Readable");
})
.on("finish", () => {
this.logger('Streamer', station.name + " / " + "Finished");
})
.on("error", error => {
this.logger('Streamer', station.name + " / " + "Error" + "\n" + error);
});
audioPlayer audioPlayer
.on('playing', () => { .on('playing', () => {
this.logger('Streamer', station.name + " / " + "Playing"); this.logger('Streamer', station.name + " / " + "Playing");
@ -88,6 +77,7 @@ module.exports = class {
.on('idle', () => { .on('idle', () => {
this.logger('Streamer', station.name + " / " + "Idle"); this.logger('Streamer', station.name + " / " + "Idle");
audioPlayer.removeAllListeners(); audioPlayer.removeAllListeners();
if(this.mode == "manual" && audioPlayer.subscribers.length == 0) return;
this.play(station); this.play(station);
}) })
.on('paused', () => { .on('paused', () => {
@ -116,16 +106,12 @@ module.exports = class {
} }
listen(station) { listen(station) {
let audioPlayer = this.map.get(station.name); let audioPlayer = this.play(station);
if(!audioPlayer){
audioPlayer = this.play(station);
}
return audioPlayer; return audioPlayer;
} }
leave(client) { leave(client) {
if(!client.stations) return; if(!client.stations) return;
client.stations.forEach(station => { client.stations.forEach(station => {
this.stop(station); this.stop(station);
}); });