Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osc.lua: cycle tracks when there's only one #15186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ Configurable Options
The following options configure what commands are run when the buttons are
clicked. ``mbtn_mid`` commands are also triggered with ``shift+mbtn_left``.

When there's only one track of a type, left clicks on track buttons always cycle
it instead of using the configured command.

``title_mbtn_left_command=script-binding select/select-playlist; script-message-to osc osc-hide``

``title_mbtn_mid_command=show-text ${filename}``
Expand Down
8 changes: 6 additions & 2 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,9 @@ local function osc_init()
return ("\238\132\134" .. osc_styles.smallButtonsLlabel .. " " ..
(mp.get_property_native("aid") or "-") .. "/" .. audio_track_count)
end
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.audio_track_mbtn_left_command)
ne.eventresponder["mbtn_left_up"] = command_callback(audio_track_count == 1
and "cycle audio"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be hardcoded. It defeats the purpose of custom commands when they only work with >2 tracks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous version checked if the default command was changed and sfan made me change it. ¯\(ツ)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That depends on what the purpose of the custom command was.
Is it so the user can use his own selection script? cycling would still make sense in that case.
Or so a totally custom action can be defined for the button? (use case?)

Either way the alternative is to change the default to "" and use that to indicate this special behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous version checked if the default command was changed and sfan made me change it. ¯_(ツ)_/¯

You just add this custom handling as a script message, then it can be written as a command.

That depends on what the purpose of the custom command was.

It's for allowing arbitrary commands. It can be used to show custom track information formatting and duration when switching tracks, custom handling depending on the number of tracks, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also just leave it as it is now that right click cycles tracks again. We keep the UI consistent as kasper noted, and if you want to cycle 1 track you can right click. Otherwise I would rather add 2 more script-opts for commands with 1 track than a script message.

Copy link
Contributor

@kasper93 kasper93 Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just add this custom handling as a script message, then it can be written as a command.

This would be proper solution. Having hardcoded conditions/commands beats the purpose of having it customizable. We cannot assume certain use of those buttons, if they are customizable. I already mentioned that about enabled conditions, that currently prevent to customize forward/back buttons.

(but I still think we should keep it simple and consistent)

or user_opts.audio_track_mbtn_left_command)
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
user_opts.audio_track_mbtn_mid_command)
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.audio_track_mbtn_right_command)
Expand All @@ -1886,7 +1888,9 @@ local function osc_init()
return ("\238\132\135" .. osc_styles.smallButtonsLlabel .. " " ..
(mp.get_property_native("sid") or "-") .. "/" .. sub_track_count)
end
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.sub_track_mbtn_left_command)
ne.eventresponder["mbtn_left_up"] = command_callback(sub_track_count == 1
and "cycle sub"
or user_opts.sub_track_mbtn_left_command)
ne.eventresponder["shift+mbtn_left_up"] = command_callback(user_opts.sub_track_mbtn_mid_command)
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.sub_track_mbtn_right_command)

Expand Down
Loading