discord-player: player stucks randomly on queue.

Since last week, player stucks randomly on any queue index. skipping the track doesn’t seems to work. After a track ends, the player doesn’t continue to the next track on the queue, instead it stops playing audio and stays on the voice channel with no audio. I think it might be a bug on the queue system (?)

player.events.on("playerStart", async (queue, track) => {
    if (guildHandler.get(queue.guild)) {
        // last change here
        try {
            if (guildHandler.get(queue.guild).commandName === 'play' && !queue.tracks.data.length) {
                await guildHandler.get(queue.guild).followUp({embeds : [Embed.musicPlaying(track)]});
            }
            else {
                await guildHandler.get(queue.guild).channel.send({embeds : [Embed.musicPlaying(track)]});
            }
             // guildHandler.set(queue.guild, newInteraction);
        }
        catch (error) {
            console.log(error);
            return void console.log("Error on playerStart : " + error);
        }
        finally {
            console.log("playerStart initiated");
        }
    }
       
});

image playerInitiated? but the message doesn’t seem to be sent on discord. And error doesn’t seem to be caught. Anyways I’m new to discord-player. Sorry for any misunderstanding.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16

Most upvoted comments

@kensunjaya I see your bridge provider is youtube, which youtube library are you using? Can you go through each of these until one works https://github.com/Androz2091/discord-player?tab=readme-ov-file#streaming-library? If none of those work, try looking into https://github.com/retrouser955/discord-player-youtubei

After some investigations, turns out that it was the youtube library being unstable. I used ytdl-core and when I switched to discord-player-youtubei it became a lot more stable. Thank you for the help

this can be used to identify the current stage we are in, in this case playing

For some tracks, this line never appears - I think there are examples of a working and not-working track in the logs in this thread, although I haven’t looked very closely.

After some messing around, setting skipFFmpeg: false seems to make it occur much less frequently (haven’t run into it yet)

🙂 if this is the case, then the streaming library you are using failed to stream the content. Streaming it via ffmpeg seems to work for you, you can keep it like that. skipFFmpeg mode is turned on by default to avoid instantiating ffmpeg when alternative way of streaming exists, which saves a lot of resources.

your code is prone to race conditions, please follow this pattern.

const queue = player.nodes.create(...);
const result = await player.search(...);

// acquire task entry
const entry = queue.tasksQueue.acquire();

// wait for previous task to be released and our task to be resolved
await entry.getTask();

// add track(s) (this will add playlist or single track from the result)
queue.addTrack(result);

try {
    // if player node was not previously playing, play a song
    if (!queue.isPlaying()) await queue.node.play();
} finally {
    // release the task we acquired to let other tasks to be executed
    // make sure you are releasing your entry, otherwise your bot won't
    // accept new play requests
    queue.tasksQueue.release();
}