Closed stax76 closed 5 years ago
"easier" is relative. The lua and js code for key binding don't do any magic, they simply define the mp.add_key_binding
functions as wrapper around other mpv commands, and use script messages to handle the callbacks. E.g. the JS binding is: https://github.com/mpv-player/mpv/blob/master/player/javascript/defaults.js#L141
Whether or not it's easier for you to utilize existing lua/js code and interface it to your dotnet thingy, or duplicate the wrapper yourself in dotnet - is up to you.
In defaults.js I found the commands define-section and enable-section, that looks promising, thanks.
Works great, thanks again!
You're welcome.
Note that the define-section
interface is subject to change: https://mpv.io/manual/master/#input-commands-that-are-possibly-subject-to-change , so if it does, your code might break (and similarly, the internal lua and js key bindings code would need to change as well).
Do you know why it might change?
No, but I guess that whoever wrote it thought that it's not the cleanest interface and that in the future it could be replaced by something else. But that's a guess.
i guess that was resolved.
Hello,
there is a user of mpv.net who wants to add a key binding with dotnet using the client API. I tried to achieve this and think it's only possible by generating and running JavaScript code and then communicate between JavaScript and dotnet via script-message command and client-message event, is there not an easier way?