Skip to content

Commit

Permalink
🐛 fix: Broken Spotify player
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzuZensai committed Jun 15, 2024
1 parent c7d579c commit 122e52a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/providers/DiscordMusicPlayerTempFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class DiscordMusicPlayerInstance {
if (previousTrack) this.previousTrack = previousTrack;

if (this.queue.track.length > 0) {
this.playTrack(this.queue.track[0]);
await this.playTrack(this.queue.track[0]);
}
}
}
Expand Down Expand Up @@ -375,13 +375,23 @@ export class DiscordMusicPlayerInstance {
);

resource = createAudioResource(stream.stream, {
inputType: stream.type
//inputType: stream.type
});
this.actualPlaybackURL = search.url;
}

this.player.play(resource);
this.voiceConnection.subscribe(this.player);

let timeout = 0;
while (!resource.started && timeout < 10000) {
console.log('Waiting for resource to start');
await new Promise((resolve) => setTimeout(resolve, 100));
timeout += 100;

if (timeout >= 10000)
this.events.emit('error', new PlayerErrorEvent(this, new Error('Resource took too long to start')));
}
} catch (error: any) {
this.events.emit('error', new PlayerErrorEvent(this, error));
this.skipTrack();
Expand Down

0 comments on commit 122e52a

Please sign in to comment.