invidious icon indicating copy to clipboard operation
invidious copied to clipboard

[Enhancement] Shuffle/Loop playlist

Open hellojaccc opened this issue 4 years ago • 13 comments

Is your enhancement request related to a problem? Please describe.

I use invidious for listening music. It currently doesn't have ability to shuffle or loop playlist. It's annoying since it just stops playing when it reaches the last video of playlist. Describe the solution you'd like

It'd be great to shuffle or loop playlist. Describe alternatives you've considered

Always loop playlist option in settings Additional context

Screenshot_20211211_175453 ^ Youtube's playlist control

hellojaccc avatar Dec 11 '21 08:12 hellojaccc

I added an experimental loop setting on my instance, but the current implementation has some drawbacks when dealing with bigger playlist >50 videos. This is the code I use to get the "first" video url with out the need of extra api calls

if  (xhr.response.nextVideo) {
...
} else if (video_data.params.always_loop_playlist) {
      player.on("ended", function () {
            	location.assign(
                document.getElementById("playlist").childNodes[2].childNodes[1].childNodes[1].childNodes[1].href);
            });
   }

But this has the drawback that after 50 videos the offset controls what the first video is but I'm working on a "right" way to improve the feature and then I would open a pr after some testing^^

89Q12 avatar Dec 31 '21 12:12 89Q12

Would love to have this :+1:

CartoonFan avatar Aug 15 '22 12:08 CartoonFan

@CartoonFan I have a shuffle mode live on my instance but its for all playlists and can be disabled in the settings but my instance is not on list currently.. But you can check it out on my playlist but it has some obvious errors still but will get there Would like to hear feedback :)

89Q12 avatar Aug 15 '22 15:08 89Q12

Sorry for the late reply @11Tuvork28! I tried out your shuffle mode; it seems to work quite well! I don't know if I can directly make use of it (I normally use the tiekoetter instance), but it's good to know something like this is out there. Were you able to make any progress on looping playlists?

CartoonFan avatar Aug 17 '22 03:08 CartoonFan

All good, yes I'm working on some javascript code that would solve all the problems with my current solution and has the possibility to be extended with more functions in the future. Like creating temporary playlists :) But it will be sometime till I get it to work, but will keep you updated

89Q12 avatar Aug 17 '22 07:08 89Q12

I added an experimental loop setting on my instance, but the current implementation has some drawbacks when dealing with bigger playlist >50 videos. This is the code I use to get the "first" video url with out the need of extra api calls

if  (xhr.response.nextVideo) {
...
} else if (video_data.params.always_loop_playlist) {
      player.on("ended", function () {
            	location.assign(
                document.getElementById("playlist").childNodes[2].childNodes[1].childNodes[1].childNodes[1].href);
            });
   }

But this has the drawback that after 50 videos the offset controls what the first video is but I'm working on a "right" way to improve the feature and then I would open a pr after some testing^^

Feel free to submit your code, even if it is experimental.

@SamantazFox I guess we could have an experimental section in the player preferences for this type of stuff?

unixfox avatar Aug 17 '22 07:08 unixfox

I'm wondering how youtube does the shuffling? Is there a request parameter for that? If yes, could we use that instead of rolling our own (except for invidious playlists)?

@SamantazFox I guess we could have an experimental section in the player preferences for this type of stuff?

Yes, agreed!

SamantazFox avatar Aug 21 '22 14:08 SamantazFox

@11Tuvork28 Would you mind contributing to the code in order to add your js code as an experimental feature in Invidious?

unixfox avatar Aug 23 '22 19:08 unixfox

Yeah sure would love to, once I'm done moving which will be tomorrow I will start working on it after finishing another PR^^ Would comeback to this tomorrow once I thought about how to implement it and ask you all if you think its fine or if it could be done better.

89Q12 avatar Aug 23 '22 19:08 89Q12

So I thougt about it and I think it would be best if we use different js files for that to save bandwidth, since I only modified watch.js so far. I would create a new entry in the preferences and add watch_experimental.js which will then be send instead of the original or the other way around. Since I really don't want dead js code send to the client for obvious reasons.

What love to hear your thoughts on this :)

89Q12 avatar Aug 24 '22 18:08 89Q12

I work a litle more on it, @CartoonFan give it a try :) Also I implemented temporary playlists like Youtube but they persist reloads and you dont need to be logged in.

89Q12 avatar Sep 10 '22 17:09 89Q12

@11Tuvork28 Shuffle seems to work, but I can't get playlists to autoplay, so it's hard to test the loop function. The settings seem to be fine, so...not really sure :shrug:

Good work so far, though! :+1:

CartoonFan avatar Sep 10 '22 19:09 CartoonFan

Yeah my bad I messed up an if statement^^ but thanks for the feedback will keep working on this.

89Q12 avatar Sep 10 '22 19:09 89Q12