diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-04-27 18:10:08 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-10-09 20:40:31 +0200 |
commit | 9e57927af1adb372a11800d1b9e603ee4639ac2a (patch) | |
tree | 2013ed1d882612d4d39cebe3c9f56b131cef7b30 /player/lua | |
parent | 74e215e9bf19c1a101c6ea1006bb1f5044dcde90 (diff) | |
download | mpv-9e57927af1adb372a11800d1b9e603ee4639ac2a.tar.bz2 mpv-9e57927af1adb372a11800d1b9e603ee4639ac2a.tar.xz |
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.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/stats.lua | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua index ab83028f8f..748fa15f7c 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -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 |