jonniek / mpv-playlistmanager

Mpv lua script to create and manage playlists
The Unlicense
551 stars 42 forks source link

[Feature Request]: Toggleable Shuffle #82

Closed NaiveInvestigator closed 2 years ago

NaiveInvestigator commented 2 years ago

What this feature does is that, it shuffles the playlist if on but if turned off it will return to its original playlist.

Sorry bother you if this was already implemented but I can't figure out how to do it using this script. As you know using cycle shuffle doesn't actually work in runtime so I thought of using this script to do exactly that.

jonniek commented 2 years ago

Add this in input.conf KEY script-message playlistmanager shuffle to suffle at runtime. Although there is no function to reverse it. What use case do you have to return to original?

NaiveInvestigator commented 2 years ago

I need it cause sometimes i press shuffle by mistake, un-shuffling it would help in that case. mostly. And sometimes tho it is rare, while listening to songs I listen to some album songs in order that is why. But mostly it the first scenario that happens to me frequently and is annoying lol.

NaiveInvestigator commented 2 years ago

nvm I think i found a way to do it.

Using this js script:

var state = 0

var commands = [
    'playlist-shuffle',
    'playlist-unshuffle'
]

function perform_action() {
    mp.command(commands[state])
    state = (state + 1) % commands.length
}

mp.add_key_binding('i','toggle-shuffle', perform_action)

Thank you for the help! Feel free to close this issue.

jonniek commented 2 years ago

playlist-unshuffle cool I didn't know about this :+1:

I feel like it's a bit waste to re-implement that for this script. I think maybe this script shouldn't include a shuffle anyway nowadays. Not sure if anyone actually uses it over the native shuffle.