Create event listeners once in Streamer class

This commit is contained in:
Christer Warén 2023-06-08 00:30:01 +03:00
parent 408c5aaab8
commit 2579549f0b

View File

@ -64,13 +64,6 @@ export default class Streamer {
});
}
this.map.set(station.name, audioPlayer);
}
const url = station.stream[station.stream.default];
const resource = createAudioResource(url);
audioPlayer.play(resource);
audioPlayer
.on(AudioPlayerStatus.Playing, () => {
logger('Streamer', station.name + " / " + "Playing");
@ -87,6 +80,14 @@ export default class Streamer {
.on(AudioPlayerStatus.AutoPaused, () => {
logger('Streamer', station.name + " / " + "AutoPaused");
})
this.map.set(station.name, audioPlayer);
}
const url = station.stream[station.stream.default];
const resource = createAudioResource(url);
audioPlayer.play(resource);
return audioPlayer;
}