🐛 fix: Stream crash

This commit is contained in:
2024-06-16 01:20:37 +07:00
parent 0e4942d2f7
commit 9dd899340a
+14 -15
View File
@@ -339,15 +339,15 @@ export class DiscordMusicPlayerInstance {
]); ]);
const streamFile = fs.createReadStream(`./temp/${track.id}.mp3`); const streamFile = fs.createReadStream(`./temp/${track.id}.mp3`);
const stream = await playdl.stream(track.url); //const stream = await playdl.stream(track.url);
stream.stream = streamFile; const stream = streamFile;
Logger.verbose( // Logger.verbose(
LOGGING_TAG, // LOGGING_TAG,
`New stream created, type: ${stream.type}, url: ${track.url}, Guild: ${this.voiceChannel.guild.id}, VoiceChannel: ${this.voiceChannel.id}` // `New stream created, type: ${stream.type}, url: ${track.url}, Guild: ${this.voiceChannel.guild.id}, VoiceChannel: ${this.voiceChannel.id}`
); // );
resource = createAudioResource(stream.stream, { resource = createAudioResource(stream, {
//inputType: stream.type //inputType: stream.type
}); });
this.actualPlaybackURL = track.url; this.actualPlaybackURL = track.url;
@@ -366,15 +366,15 @@ export class DiscordMusicPlayerInstance {
]); ]);
const streamFile = fs.createReadStream(`./temp/${search.id}.mp3`); const streamFile = fs.createReadStream(`./temp/${search.id}.mp3`);
const stream = await playdl.stream(search.url); //const stream = await playdl.stream(search.url);
stream.stream = streamFile; const stream = streamFile;
Logger.verbose( // Logger.verbose(
LOGGING_TAG, // LOGGING_TAG,
`New stream created, type: ${stream.type}, url: ${track.url}, Guild: ${this.voiceChannel.guild.id}, VoiceChannel: ${this.voiceChannel.id}` // `New stream created, type: ${stream.type}, url: ${track.url}, Guild: ${this.voiceChannel.guild.id}, VoiceChannel: ${this.voiceChannel.id}`
); // );
resource = createAudioResource(stream.stream, { resource = createAudioResource(stream, {
//inputType: stream.type //inputType: stream.type
}); });
this.actualPlaybackURL = search.url; this.actualPlaybackURL = search.url;
@@ -385,7 +385,6 @@ export class DiscordMusicPlayerInstance {
let timeout = 0; let timeout = 0;
while (!resource.started && timeout < 10000) { while (!resource.started && timeout < 10000) {
console.log('Waiting for resource to start');
await new Promise((resolve) => setTimeout(resolve, 100)); await new Promise((resolve) => setTimeout(resolve, 100));
timeout += 100; timeout += 100;