1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-20 02:09:52 +00:00

stats: make the OSD usable in audio-only mode

Previously, the script would throw garbage (ASS tags) at the terminal
when the bound key was pressed. This changes the behaviour to _not_
print any ASS tags (and replace those which can be interpreted by the
terminal) if there's no video.

I cleaned the patch up since you mentioned you were busy. As I said
before, there is absolutely no problem with calling mpv to display
strings to the OSD without any video. They'll just go straight to the
terminal just as they would with an active VO.
This commit is contained in:
Rostislav Pehlivanov 2015-04-27 18:10:08 +01:00 committed by wm4
parent 74e215e9bf
commit 9e57927af1

View File

@ -13,6 +13,7 @@
require 'mp.options'
local o = {
no_osd = 0,
duration = 3,
-- text formatting
font = "Source Sans Pro",
@ -29,6 +30,13 @@ local o = {
prop_indent = "\\h\\h\\h\\h\\h",
kv_sep = "\\h\\h", -- key<kv_sep>value
b1 = "{\\b1}",
b0 = "{\\b0}",
i1 = "{\\i1}",
i0 = "{\\i0}",
u1 = "{\\u1}",
u0 = "{\\u0}",
-- Custom header for ASS tags to format the text output.
-- Specifying this will ignore the text formatting values above and just
-- use this string instead.
@ -44,7 +52,21 @@ function main()
video = "",
audio = ""
}
if mp.get_property("video-codec") == nil then
o.nl = "\n"
duration = mp.get_property("length")
o.prop_indent = "\t"
o.kv_sep = ""
o.b1 = ""
o.b0 = ""
o.i1 = ""
o.i0 = ""
o.u1 = ""
o.u0 = ""
o.no_osd = 1
end
add_header(stats)
add_file(stats)
add_video(stats)
@ -117,6 +139,9 @@ end
function add_header(s)
if o.no_osd == 1 then
return
end
if o.custom_header and o.custom_header ~= "" then
s.header = set_ASS(true) .. o.custom_header
else
@ -161,6 +186,9 @@ end
function no_ASS(t)
if o.no_osd == 1 then
return t
end
return set_ASS(false) .. t .. set_ASS(true)
end
@ -176,13 +204,13 @@ end
function b(t)
return "{\\b1}" .. t .. "{\\b0}"
return o.b1 .. t .. o.b0
end
function i(t)
return "{\\i1}" .. t .. "{\\i0}"
return o.i1 .. t .. o.i0
end
function u(t)
return "{\\u1}" .. t .. "{\\u0}"
return o.u1 .. t .. o.u0
end