hopollo / OBS-Youtube-Player

Designed for OBS Browser source to display/play a song/playlist fully automatically with customs params.
57 stars 33 forks source link

Select random index for playlists #6

Closed sugoidogo closed 1 year ago

sugoidogo commented 2 years ago

I'm consistently getting the same song every time I load up this source in OBS, so I've added some code to randomize which video gets loaded first in a playlist.

hopollo commented 2 years ago

Hi,

Thanks for contributing to this project, can you send more info about your issue please ?

Your pull request is fine, i didn't encountered this randomize issue i guess, and would like to undrestand it better :)

Thanks.

sugoidogo commented 2 years ago

I'm actually not experiencing it anymore, but it used to be that the same video in a playlist was being played first every time, even with random=true. After re-installing my OS, I don't actually need the parameter I added.

sugoidogo commented 2 years ago

It's just occurred to me that I've been using my branch, and so using random without index is actually giving me the default randomIndexMax=10 I set up, so I may still be benefiting from my changes. It is late at night for me as I write this, so I will test later and comment again with my results.

rody62 commented 2 years ago

Hello, I got the same problem as sugoidogo: If I access to this: https://hopollo.github.io/OBS-Youtube-Player/?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK&volume=10 I always get the same song playing first, that is the 2nd of the list: "Tobu - If I Disappear"

Thanks to sugoidogo's, first song is correctly random. The next one is not random though, even with sugoidogo's. It is always the next in the list.

sugoidogo commented 2 years ago

Sorry I never got around to testing this, a lot happened in my personal life since I said I would do so. @rody62 with the url you gave, I would expect no randomization. There is no random=true among the query parameters. What url did you use for my fork? To have fully random video selection, I use random=true and randomIndexMax=300 ( I use a very long playlist )

rody62 commented 2 years ago

Ah yes it works with random=true. Thank you.

It's just that random default value is wrong: let random = url.searchParams.get("random") || true; [...] random === "true" && player.setShuffle(true); But true and "true" are not equals. To fix that, here is the PR:

8