From c519a436200253636b37fa30768cfb2c3fdf0ed1 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 29 Jan 2022 22:01:03 -0500 Subject: Fix livestreams --- src/services/player.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/services/player.ts b/src/services/player.ts index fc4b989..f46240a 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -52,14 +52,11 @@ export default class { } async connect(channel: VoiceChannel): Promise { - const conn = joinVoiceChannel({ + this.voiceConnection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, - // @ts-expect-error (see https://github.com/discordjs/voice/issues/166) adapterCreator: channel.guild.voiceAdapterCreator, }); - - this.voiceConnection = conn; } disconnect(): void { @@ -94,7 +91,12 @@ export default class { } const stream = await this.getStream(currentSong.url, {seek: positionSeconds}); - this.audioPlayer = createAudioPlayer(); + this.audioPlayer = createAudioPlayer({ + behaviors: { + // Needs to be somewhat high for livestreams + maxMissedFrames: 50, + }, + }); this.voiceConnection.subscribe(this.audioPlayer); this.audioPlayer.play(createAudioResource(stream, { inputType: StreamType.WebmOpus, @@ -141,7 +143,12 @@ export default class { try { const stream = await this.getStream(currentSong.url); - this.audioPlayer = createAudioPlayer(); + this.audioPlayer = createAudioPlayer({ + behaviors: { + // Needs to be somewhat high for livestreams + maxMissedFrames: 50, + }, + }); this.voiceConnection.subscribe(this.audioPlayer); this.audioPlayer.play(createAudioResource(stream, { inputType: StreamType.WebmOpus, -- cgit v1.2.3