Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Detecting the End of Tracks #692

Open
confusedkernel opened this issue Apr 7, 2022 · 1 comment
Open

Not Detecting the End of Tracks #692

confusedkernel opened this issue Apr 7, 2022 · 1 comment

Comments

@confusedkernel
Copy link

As mentioned above, when the track finishes it doesn't automatically skip to the next track.
After a bit of debugging, I found out that it doesn't seem like my current code fires the onTrackEnd event at all.

    public void nextTrack() {
        this.player.startTrack(queue.poll(), false);
        currentSong();
        System.out.println("skipped");
    }

    @Override
    public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
        System.out.println("does it work?");
        if (endReason.mayStartNext) {
            nextTrack();
            currentSong();
        }
    }

I've searched for any possible solution but so far none of the solutions worked for me, can someone help?
My repository of the bot, the code is in MusicManager.

@MCOfficer
Copy link
Contributor

MCOfficer commented Apr 7, 2022

You need to register your AudioEventAdapter with the player (called TrackScheduler in the example):

scheduler = new TrackScheduler(player);
player.addListener(scheduler);

Unless I missed something you're not doing that anywhere in your code. You just initialize your AudioEventAdapter, and that's it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants