jonniek / mpv-playlistmanager

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

Keep display playlist on key down #110

Closed pierretom closed 1 year ago

pierretom commented 1 year ago

I would like to keep display playlist on key down, like the F8 default keybinding. Is possible?

jonniek commented 1 year ago

I added a peek_at_playlist keybinding that will work like you described.

pierretom commented 1 year ago

Wow that was fast, thanks. Is possible to use playlist_display_timeout when peek_at_playlist is set/used? Also key_playfile does not seem to work using peek_at_playlist keybinding.

xfzv commented 1 year ago

I added a peek_at_playlist keybinding that will work like you described.

How to bind this via Script messages?

Thanks.

jonniek commented 1 year ago

How to bind this via Script messages?

You can't, since it's a complex keybinding that measures key down and up. Script messages cannot do that as far as I know.

Is possible to use playlist_display_timeout when peek_at_playlist is set/used?

I was considering this, but doesn't that kind of defeat the purpose? Why would you want the playlist to disappear while holding down the peek button?

Also key_playfile does not seem to work using peek_at_playlist keybinding.

This is a bit tricky since any other key press executes the peek key up event, which actually unbinds the playfile key before it is executed. But I figured out a hack how to do it with dynamic binds. I added a tiny delay to removing the keybinds, which lets the interrupting key execute it's command first. In this case key_playfile. If you interrupt with a navigation key it will take over playlist rendering from the peek and be as if it was toggled on normally. This hack might cause some weird edgecases so let me know if it doesn't work as expected.

xfzv commented 1 year ago

How to bind this via Script messages?

You can't, since it's a complex keybinding that measures key down and up. Script messages cannot do that as far as I know.

I see. I'd like to use it with Natural-Harmonia-Gropius/InputEvent, not sure if that's possible.

jonniek commented 1 year ago

Interesting script. I added script events for peek. If I understand their documentation correctly you could:

RIGHT           script-message-to playlistmanager peek_open      #@press
RIGHT           script-message-to playlistmanager peek_close     #@release
pierretom commented 1 year ago

Is possible to use playlist_display_timeout when peek_at_playlist is set/used?

I was considering this, but doesn't that kind of defeat the purpose? Why would you want the playlist to disappear while holding down the peek button?

I want that the playlist disappear when peek_at_playlist key is released and after playlist_display_timeout is reached.

Also key_playfile does not seem to work using peek_at_playlist keybinding.

This is a bit tricky. I can't make it work for both dynamic_binds=true and dynamic_binds=false. Which one do you use? I could make it work for that one.

The idea would be to either:

* Do not bind keys during peek, but bind the same key you would use for `key_playfile` as `playlist-next` in input.conf. This way the bind would still work while peeking.

* Bind keys during peek, but require `dynamic_binds=false` to use keys while peeking

There might be some trick to delay the unbinding of keys when peek is released by another key press. I need to experiment a bit.

The idea was to navigate and use the playlist while holding peek_at_playlist keybind. But dynamic_binds=false do the job correctly, thanks.

jonniek commented 1 year ago

I want that the playlist disappear when peek_at_playlist key is released and after playlist_display_timeout is reached.

Do you mean:

  1. hide it after peek is released, but at the very least display it for the playlist_display_timeout duration?
  2. hide it after either peek is released or playlist_display_timeout is reached, whichever happens first?

I feel like both are a bit unexpected behaviours for a hold down button.

The idea was to navigate and use the playlist while holding peek_at_playlist keybind. But dynamic_binds=false do the job correctly, thanks

I changed it a bit. Should work with dynamic binds now too. See my edited comment above for details.

pierretom commented 1 year ago

Do you mean:

1. hide it after peek is released, but at the very least display it for the playlist_display_timeout duration?

Yes, this one.

I changed it a bit. Should work with dynamic binds now too. See my edited comment above for details.

Ok.

xfzv commented 1 year ago

Interesting script. I added script events for peek.

Thank you. I had to use script-message instead of script-message-to to get it to work though (if you want to add it to the README for example). I used the following to achieve what I wanted:

KEY    script-message playlistmanager peek_open      #@click
KEY    script-message playlistmanager peek_open      #@repeat
KEY    script-message playlistmanager peek_close     #@release
jonniek commented 1 year ago

Do you mean:

1. hide it after peek is released, but at the very least display it for the playlist_display_timeout duration?

Yes, this one.

I added an optional setting to make it work like this peek_respect_display_timeout.

Sorry @xfzv I changed the playlist messages to be more generic because I noticed the "peek_show" is same as "show playlist". So the below bindings should work for you.

KEY    script-message playlistmanager show playlist      #@click
KEY    script-message playlistmanager show playlist      #@repeat
KEY    script-message playlistmanager close              #@release
xfzv commented 1 year ago

Sorry @xfzv I changed the playlist messages to be more generic because I noticed the "peek_show" is same as "show playlist". So the below bindings should work for you.

KEY    script-message playlistmanager show playlist      #@click
KEY    script-message playlistmanager show playlist      #@repeat
KEY    script-message playlistmanager close              #@release

The following no longer works as expected after updating:

KEY    script-message playlistmanager show playlist      #@click

Before, when pressing KEY once, the playlist would be toggled indefinitely. Now, it disappears after 15~20 seconds. Tried with both peek_respect_display_timeout=no and peek_respect_display_timeout=yes but it doesn't make any difference.

jonniek commented 1 year ago

Oh right that is true. You should be able to do script-message playlistmanager show playlist 100000 instead to set a custom timeout. These messages are not using the peek logic so the peek_respect_display_timeout is not affecting it. Do you think the peek_respect_display_timeout=true would be useful for script messages?

xfzv commented 1 year ago

Oh right that is true. You should be able to do script-message playlistmanager show playlist 100000 instead to set a custom timeout.

I'd like to have an "infinite" timeout (the playlist is toggled when I press KEY, until I press KEY again). Is it possible? I tried to use 0 but it doesn't work.

jonniek commented 1 year ago

I added functionality for an infinite timeout when using value 0. You can use the existing show playlist toggle messages to use the same script message for opening and closing the playlist with no timeouts.

xfzv commented 1 year ago

I added functionality for an infinite timeout when using value 0. You can use the existing show playlist toggle messages to use the same script message for opening and closing the playlist with no timeouts.

Thank you, works just fine!

pierretom commented 1 year ago

Good job and thanks jonniek!