History

client API, lua: add new API for setting OSD overlays

Lua scripting has an undocumented mp.set_osd_ass() function, which is used by osc.lua and console.lua. Apparently, 3rd party scripts also use this. It's probably time to make this a public API. The Lua implementation just bypassed the libmpv API. To make it usable by any type of client, turn it into a command, "osd-overlay". There's already a "overlay-add". Ignore it (although the manpage admits guiltiness). I don't really want to deal with that old command. Its main problem is that it uses global IDs, while I'd like to avoid that scripts mess with each others overlays (whether that is accidentally or intentionally). Maybe "overlay-add" can eventually be merged into "osd-overlay", but I'm too lazy to do that now. Scripting now uses the commands. There is a helper to manage OSD overlays. The helper is very "thin"; I only want to force script authors to use the ID allocation, which may help with putting multiple scripts into a single .lua file without causing conflicts (basically, avoiding singletons within a script's environment). The old set_osd_ass() is emulated with the new API. The JS scripting wrapper also provides a set_osd_ass() function, which calls internal mpv API. Comment that part (to keep it compiling), but I'm leaving it to @avih to finish the change.

wm4 committed 6 years ago

Commit 07287261 parent 96932fe11 files · +292 −68Browse files

Showing the changes to player/javascript.c (1 of 11 files). Show all

Unified · Split

player/javascript.c+1−1
@@ -738,7 +738,7 @@ static void script_set_osd_ass(js_State *J) · 737 unmodified lines
738 int res_x = jsL_checkint(J, 1);738 int res_x = jsL_checkint(J, 1);
739 int res_y = jsL_checkint(J, 2);739 int res_y = jsL_checkint(J, 2);
740 const char *text = js_tostring(J, 3);740 const char *text = js_tostring(J, 3);
741 osd_set_external(ctx->mpctx->osd, ctx->client, res_x, res_y, (char *)text);741 //osd_set_external(ctx->mpctx->osd, ctx->client, res_x, res_y, (char *)text);
742 mp_wakeup_core(ctx->mpctx);742 mp_wakeup_core(ctx->mpctx);
743 push_success(J);743 push_success(J);
744}744}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t