mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-10 05:00:18 +00:00
Update Streamer class
This commit is contained in:
parent
93a4f3e0c4
commit
d67fa68445
@ -49,12 +49,22 @@ module.exports = class {
|
||||
play(station) {
|
||||
let audioPlayer = this.map.get(station.name);
|
||||
if(!audioPlayer) {
|
||||
audioPlayer = createAudioPlayer({
|
||||
behaviors: {
|
||||
noSubscriber: NoSubscriberBehavior.Play,
|
||||
maxMissedFrames: Math.round(5000 / 20),
|
||||
},
|
||||
});
|
||||
if(this.mode == "auto"){
|
||||
audioPlayer = createAudioPlayer({
|
||||
behaviors: {
|
||||
noSubscriber: NoSubscriberBehavior.Play,
|
||||
maxMissedFrames: Math.round(5000 / 20),
|
||||
},
|
||||
});
|
||||
}
|
||||
if(this.mode == "manual"){
|
||||
audioPlayer = createAudioPlayer({
|
||||
behaviors: {
|
||||
noSubscriber: NoSubscriberBehavior.Stop,
|
||||
maxMissedFrames: Math.round(5000 / 20),
|
||||
},
|
||||
});
|
||||
}
|
||||
this.map.set(station.name, audioPlayer);
|
||||
}
|
||||
const url = station.stream[station.stream.default];
|
||||
@ -77,22 +87,18 @@ module.exports = class {
|
||||
})
|
||||
.on('idle', () => {
|
||||
this.logger('Streamer', station.name + " / " + "Idle");
|
||||
this.play(station);
|
||||
})
|
||||
.on('paused', () => {
|
||||
this.logger('Streamer', station.name + " / " + "Paused");
|
||||
this.play(station);
|
||||
})
|
||||
.on('buffering', () => {
|
||||
this.logger('Streamer', station.name + " / " + "Buffering");
|
||||
})
|
||||
.on('autopaused', () => {
|
||||
this.logger('Streamer', station.name + " / " + "AutoPaused");
|
||||
this.play(station);
|
||||
})
|
||||
.on('error', error => {
|
||||
this.logger('Streamer', station.name + " / " + "Error" + "\n" + error);
|
||||
this.play(station);
|
||||
});
|
||||
return audioPlayer;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user