player/lua: implement OSD layer in Lua#18097
Conversation
Add a command line option to activate the Lua OSD. --osd-lua=yes to activate, --osd-lua=no to deactivate, same as other similar options. Default value is false. Signed-off-by: Alexandre Delgado <alexandre.delgado@tecnico.ulisboa.pt> Co-authored-by: Ricardo Fonseca <ricardofonseca94321@tecnico.ulisboa.pt>
A Lua script that draws every visual component of the OSD and provides several user options for easy customization just like osc.lua does. Configuration file for the Lua OSD goes in ~/.config/mpv/script-opts/osd.conf This script suppresses the OSD written in C when it is run. Signed-off-by: Alexandre Delgado <alexandre.delgado@tecnico.ulisboa.pt> Co-authored-by: Ricardo Fonseca <ricardofonseca94321@tecnico.ulisboa.pt>
Minor changes so that mpv's code recognizes and loads the Lua script for the OSD. This script is only loaded and run if the --osd-lua option is provided with "yes". Signed-off-by: Alexandre Delgado <alexandre.delgado@tecnico.ulisboa.pt> Co-authored-by: Ricardo Fonseca <ricardofonseca94321@tecnico.ulisboa.pt>
Created two tests to ensure proper behaviour of the Lua OSD. One test ensures that mpv is able to load a video file with the Lua OSD running and the other simulates both OSDs and compares values like volume or paused state to ensure no value of the video is being changed by the Lua OSD. Closes mpv-player#16991 Signed-off-by: Alexandre Delgado <alexandre.delgado@tecnico.ulisboa.pt> Co-authored-by: Ricardo Fonseca <ricardofonseca94321@tecnico.ulisboa.pt>
|
Why is this needed? Third party OSC scripts can already disable the OSD and implement their own if they like. Why does mpv need to carry this redundant built in script? |
|
I don't think the idea is bad in isolation, but the current OSD is working without lua support compiled into mpv. While there is argument, that such builds are not common/useful, as lua vm is pretty small and portable. The "reimplement in script" strategy is actually against the design of mpv as established for years. |
The idea was to make it easier for third party users to customize the already existing OSD without having to implement something from scratch, like the feature proposal mentions. It would require less technical knowledge to make the OSD match their custom OSC, or to even just have their own OSD.
That makes sense, it's good that someone is able compile mpv without needing Lua at all and have the OSD working perfectly. I hope I'm not mistaken but these changes don't impact the existing OSD in any way so it should still be working as before without Lua support compiled into mpv This was just to provide an additional option, in case Lua support was active, to be able to interact with it in Lua. It doesn't change the existing implementation of the OSD, just suppresses it with |
|
Where is ctx defined? Line 40 of this diff in |
This would introduce maintenance costs. If someone makes a change in C OSD, should they also synchronize it to Lua OSD? |
|
It's really odd to keep two versions. |
|
Yes the C version could be dropped but it's like kasper said, OSD working without Lua support compiled into mpv is how things are currently and it seems like a good approach to not require Lua. From the point of view of a third-party developer, I imagine one could want only the OSD working for a more minimalistic look, since OSD and OSC are seperate things and the OSC can be disabled with command line options. So in those cases they'd only need to configure the OSD, and it'd be simpler. I think keeping the OSC and OSD as seperate things in the customization side of things makes sense and allows to cover a wider range of specific use cases for customization |
About the maintenance, that is a very good point. We made the OSD in Lua have a similar default appearance to the one in C because it's a good starting point for customization but the OSD in Lua is functionally independent. So it wouldn't be strictly necessary to update the Lua OSD if the one in C was changed. Only if there was a desire to keep them always looking alike, or if there were changes to the hooks, but I take that would affect other Lua scripts as well |
As requested by #16991 this implements a Lua script that draws every visual component of the OSD and provides several user options for easy customization just like osc.lua does. Configuration file for the Lua OSD goes in ~/.config/mpv/script-opts/osd.conf
An additional command line option was created, --osd-lua, with default value false. The Lua OSD script suppresses the OSD written in C when it is run and is only loaded into mpv when the option --osd-lua is provided with yes.
Tests were created to ensure proper behaviour of this feature
Fixes: #16991