tomasklaen / uosc

Feature-rich minimalist proximity-based UI for MPV player.
GNU Lesser General Public License v2.1
1.82k stars 69 forks source link

Assign several actions for a OSC button #588

Open pokemaster974 opened 1 year ago

pokemaster974 commented 1 year ago

Hi, is it possible to assign several actions for a OSC button ? For example, into the default osc, we can apply 3 different actions when we click on the subtitles button :

    --cy_audio
    ne = new_element("cy_audio", "button")

    ne.enabled = (#tracks_osc.audio > 0)
    ne.content = function ()
        local aid = "–"
        if not (get_track("audio") == 0) then
            aid = get_track("audio")
        end
        return ("\238\132\134" .. osc_styles.smallButtonsLlabel
            .. " " .. aid .. "/" .. #tracks_osc.audio)
    end
    ne.eventresponder["mbtn_left_up"] =
        function () set_track("audio", 1) end
    ne.eventresponder["mbtn_right_up"] =
        function () set_track("audio", -1) end
    ne.eventresponder["shift+mbtn_left_down"] =
        function () show_message(get_tracklist("audio"), 2) end

On uosc.lua, I found this :

bind_command('audio', create_select_tracklist_type_menu_opener(
    'Audio', 'audio', 'aid', 'script-binding uosc/load-audio'
))

My goal is to have at least 2 actions : -left click -> toggle to next audio -right click -> open the audio menu

But I don't know how to do this, and if I success to do it, it will break the compatibility with you version. Maybe I can do something with overwrite-binding <name> <command> or maybe into uosc.conf but I'm not sure.

Thanks for your help !

christoph-heinrich commented 1 year ago

Quote

increasing the complexity of already pretty complex command config syntax to allow different behavior depending on a button pressing it is definitely not gonna happen

Seems like a useful thing to have though.

hooke007 commented 1 year ago

I also dislike the idea that one button share different actions. And I haven't met other media players using the similar logic.

IMO, the reason why default osc allow it is that they don't want to design a more complex UI to increase the burden of maintenance. A button with many actions seems to be the compromise solution. While uosc already had the friendly track-list menu.

tomasklaen commented 1 year ago

I'll leave the issue open, but no promises.