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

RFC: Auto advance to next song instead of repeat? #4

Open
davince72 opened this issue Jul 10, 2021 · 2 comments
Open

RFC: Auto advance to next song instead of repeat? #4

davince72 opened this issue Jul 10, 2021 · 2 comments

Comments

@davince72
Copy link

Hi, Great player I stumble upon lately after searching for AHX players. Only downside....the song is autorepeat....so it's not suited for leaving to play in background ;-)
I've looked at the code at the song seems to be restarted at this point: https://github.com/bryc/ahx-web-player/blob/master/ahx.js#L702 so it is detectable.....but i don't know how to get hold on next song in list.....this knowledge seems to be available in index.html...but i can not find a way to interact ;-)
Is there allready a setting to disable auto-repeat? Or is it possible to implement it?

@bryc
Copy link
Owner

bryc commented Jul 10, 2021

Yeah.. the player is just meant to be a simple browser. Not even Next or Prev buttons, let alone Auto Next. Maybe I will fix that at some point, but no promises.

For now, a quick patch with minimal code would be adding this second if condition to this progress bar update routine: https://github.com/bryc/ahx-web-player/blob/master/index.html#L244

            if(WebAHX.Master.Output.Player.SongEndReached)
            {
                var list = document.querySelectorAll("z");

                for(var i = 0; i < list.length; i++)
                {
                    if(list[i].className === "selected")
                    {
                        list[i + 1].click();
                        break;
                    }
                }
            }

It's not perfect, but it works... mostly. But though there's a problem now. Some songs navigate and loop freely without ever setting SongEndReached to 1. So I don't see a clean way to detect all cases. Maybe need to detect loops.

Would need more thought on this. Won't commit that patch yet but if that patch is useful if you want it offline etc, go ahead.

@davince72
Copy link
Author

Hi Bryc! Wow that was quick ;-) Many thanks. Curious what the downside could be, but for now it's great! I'll try to create/add a timer of some sort.....if song is played for more than 5 minutes....we consider it's looping and we go to the next song ;-)

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