From 7bcd525dce630c1bf2160db1cbd35dd26a534647 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Thu, 27 Jun 2024 20:00:31 +0200 Subject: [PATCH] various: sync shown track flags Show the same flags in loadfile.c, select.lua and stats.lua. The only differences are that only stats.lua prints both image and albumart because it's supposed to show detailed track information, and select.lua prints the image flag because pressing g-v doesn't show Video or Image like in loadfile.c and stats.lua. --- player/loadfile.c | 8 ++++---- player/lua/select.lua | 24 +++++++++++++++++++++--- player/lua/stats.lua | 4 ++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/player/loadfile.c b/player/loadfile.c index 2306d2b72b..0d504d4466 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -308,12 +308,12 @@ static void print_stream(struct MPContext *mpctx, struct track *t, bool indent) ADD_FLAG(b, "default", first); if (t->forced_track) ADD_FLAG(b, "forced", first); - if (t->attached_picture) - ADD_FLAG(b, "picture", first); + if (t->dependent_track) + ADD_FLAG(b, "dependent", first); if (t->visual_impaired_track) - ADD_FLAG(b, "visual_impaired", first); + ADD_FLAG(b, "visual-impaired", first); if (t->hearing_impaired_track) - ADD_FLAG(b, "hearing_impaired", first); + ADD_FLAG(b, "hearing-impaired", first); if (t->is_external) ADD_FLAG(b, "external", first); if (!first) diff --git a/player/lua/select.lua b/player/lua/select.lua index e2542f2c39..8947487c69 100644 --- a/player/lua/select.lua +++ b/player/lua/select.lua @@ -62,6 +62,25 @@ mp.add_forced_key_binding(nil, "select-playlist", function () }) end) +local function format_flags(track) + local flags = "" + + for _, flag in ipairs({ + "default", "forced", "dependent", "visual-impaired", "hearing-impaired", + "image", "external" + }) do + if track[flag] then + flags = flags .. flag .. " " + end + end + + if flags == "" then + return "" + end + + return " [" .. flags:sub(1, -2) .. "]" +end + local function format_track(track) return (track.selected and "●" or "○") .. (track.title and " " .. track.title or "") .. @@ -78,9 +97,8 @@ local function format_track(track) (track["codec-profile"] and track.type == "audio" and track["codec-profile"] .. " " or "") .. (track["demux-samplerate"] and track["demux-samplerate"] / 1000 .. - " kHz " or "") .. - (track.external and "external " or "") - ):sub(1, -2) .. ")" + " kHz " or "") + ):sub(1, -2) .. ")" .. format_flags(track) end mp.add_forced_key_binding(nil, "select-track", function () diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 7aa7b0d44e..0d7e746d7e 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -1227,8 +1227,8 @@ local function add_track(c, t, i) append(c, t["ff-index"], {prefix="FFmpeg Index:", nl="", indent=o.prefix_sep .. o.prefix_sep}) append(c, t["external-filename"], {prefix="File:"}) append(c, "", {prefix="Flags:"}) - local flags = {"default", "forced", "external", "dependent", - "hearing-impaired", "visual-impaired", "image", "albumart"} + local flags = {"default", "forced", "dependent", "visual-impaired", + "hearing-impaired", "image", "albumart", "external"} local any = false for _, flag in ipairs(flags) do if t[flag] then