ahx-web-player
ahx-web-player copied to clipboard
RFC: Auto advance to next song instead of repeat?
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?
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.
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 ;-)