From dc00ad537f74dc6010afdc5c4f03a32a8bf2793a Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Mon, 27 Mar 2017 17:44:24 +0100 Subject: osc: make title configurable and use property expansion on it --- DOCS/man/osc.rst | 8 +++++++- player/lua/osc.lua | 10 ++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst index ecb4d99244..17911bbf68 100644 --- a/DOCS/man/osc.rst +++ b/DOCS/man/osc.rst @@ -43,7 +43,7 @@ pl next ============= ================================================ title - | Displays current media-title or filename + | Displays current media-title, filename, or custom title ============= ================================================ left-click show playlist position and length and full title @@ -239,6 +239,12 @@ Configurable Options Duration of fade out in ms, 0 = no fade +``title`` + Default: ${media-title} + + String that supports property expansion that will be displayed as + OSC title. + ``tooltipborder`` Default: 1 diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 8997ae4ac6..569bb208ac 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -34,6 +34,8 @@ local user_opts = { layout = "bottombar", seekbarstyle = "bar", -- slider (diamond marker), knob (circle -- marker with guide), or bar (fill) + title = "${media-title}", -- string compatible with property-expansion + -- to be shown as OSC title tooltipborder = 1, -- border of tooltip in bottom/topbar timetotal = false, -- display total time instead of remaining time? timems = false, -- display timecodes with milliseconds? @@ -1511,12 +1513,8 @@ function osc_init() ne = new_element("title", "button") ne.content = function () - local title = mp.get_property_osd("media-title") - if not (title == nil) then - return (title) - else - return ("mpv") - end + local title = mp.command_native({"expand-text", user_opts.title}) + return not (title == "") and title or "mpv" end ne.eventresponder["mouse_btn0_up"] = function () -- cgit v1.2.3