Skip to content

Commit

Permalink
various: sync shown track flags
Browse files Browse the repository at this point in the history
Show the same flags in loadfile.c, select.lua and stats.lua. The only
differences are that only stats.lua prints 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.
  • Loading branch information
guidocella committed Jun 27, 2024
1 parent 67a8596 commit 646b914
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
8 changes: 4 additions & 4 deletions player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 20 additions & 1 deletion player/lua/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 "") ..
Expand All @@ -80,7 +99,7 @@ local function format_track(track)
(track["demux-samplerate"] and track["demux-samplerate"] / 1000 ..
" kHz " or "") ..
(track["hls-bitrate"] and track["hls-bitrate"] .. " kbps " or "")
):sub(1, -2) .. ")"
):sub(1, -2) .. ")" .. format_flags(track)
end

mp.add_forced_key_binding(nil, "select-track", function ()
Expand Down
4 changes: 2 additions & 2 deletions player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,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", "albumart", "external"}
local any = false
for _, flag in ipairs(flags) do
if t[flag] then
Expand Down

0 comments on commit 646b914

Please sign in to comment.