mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
osc: make the title toggleable between media-title and filename
Close #4221
This commit is contained in:
@@ -46,8 +46,8 @@ title
|
||||
| Displays current media-title or filename
|
||||
|
||||
============= ================================================
|
||||
left-click show playlist position and length and full title
|
||||
right-click show filename
|
||||
left-click toggle displaying media-title or filename
|
||||
right-click show playlist position and length and filename
|
||||
============= ================================================
|
||||
|
||||
cache
|
||||
@@ -239,6 +239,12 @@ Configurable Options
|
||||
|
||||
Duration of fade out in ms, 0 = no fade
|
||||
|
||||
``prefertitle``
|
||||
Default: yes
|
||||
|
||||
Display media title if available (yes) or always display the
|
||||
filename (no).
|
||||
|
||||
``tooltipborder``
|
||||
Default: 1
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ local user_opts = {
|
||||
layout = "bottombar",
|
||||
seekbarstyle = "bar", -- slider (diamond marker), knob (circle
|
||||
-- marker with guide), or bar (fill)
|
||||
prefertitle = true, -- show media-title (true) or filename (false)
|
||||
tooltipborder = 1, -- border of tooltip in bottom/topbar
|
||||
timetotal = false, -- display total time instead of remaining time?
|
||||
timems = false, -- display timecodes with milliseconds?
|
||||
@@ -101,6 +102,7 @@ local state = {
|
||||
enabled = true,
|
||||
input_enabled = true,
|
||||
showhide_enabled = false,
|
||||
prefertitle = user_opts.prefertitle
|
||||
}
|
||||
|
||||
|
||||
@@ -1511,16 +1513,18 @@ 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
|
||||
return (state.prefertitle) and
|
||||
mp.get_property_osd("media-title", "mpv") or
|
||||
mp.get_property_osd("filename", "mpv")
|
||||
end
|
||||
|
||||
ne.eventresponder["mouse_btn0_up"] = function ()
|
||||
local title = mp.get_property_osd("media-title")
|
||||
state.prefertitle = not state.prefertitle
|
||||
request_init()
|
||||
end
|
||||
|
||||
ne.eventresponder["mouse_btn2_up"] = function ()
|
||||
local title = mp.get_property_osd("filename")
|
||||
if (have_pl) then
|
||||
title = string.format("[%d/%d] %s", countone(pl_pos - 1),
|
||||
pl_count, title)
|
||||
@@ -1528,9 +1532,6 @@ function osc_init()
|
||||
show_message(title)
|
||||
end
|
||||
|
||||
ne.eventresponder["mouse_btn2_up"] =
|
||||
function () show_message(mp.get_property_osd("filename")) end
|
||||
|
||||
-- playlist buttons
|
||||
|
||||
-- prev
|
||||
|
||||
Reference in New Issue
Block a user