History

options: add --osd-playlist-entry

Allow configuring whether to print the media-title, the filename or both (as `<title> (<filename>)`) in show-text ${playlist}, the OSC playlist and in the playlist selector. Showing only titles hides information when files are badly tagged, or when it hides the track numbers of album songs. But showing filenames is not as useful as titles e.g. when playing URLs with media titles. This option lets the user choose which one to show, or show both if switching is inconvenient. The OSC's playlist_media_title script-opt is removed because this option is better since it works everywhere after configuring it once. Closes #11653. Also show the full URLs of playlist entries instead of their basenames in osc.lua and select.lua, consistently with mp_property_playlist(). For simplicity, this just checks if entries contain :// instead of replicating all of mp_is_url().

Guido Cella committed 2 years ago

Commit dc998561 parent d53aa6d8 files · +42 −17Browse files

Unified · Split

8 files
  1. DOCS/interface-changes/show-playlist-titles.txt +2 −0
  2. DOCS/man/options.rst +6 −0
  3. DOCS/man/osc.rst +0 −7
  4. options/options.c +3 −0
  5. options/options.h +1 −0
  6. player/command.c +8 −3
  7. player/lua/osc.lua +11 −6
  8. player/lua/select.lua +11 −1
DOCS/interface-changes/show-playlist-titles.txt+2−0
@@ -0,0 +1,2 @@
1+add `--osd-playlist-entry` option
2+remove `osc-playlist_media_title` script-opt
DOCS/man/options.rst+6−0
@@ -4392,6 +4392,12 @@ OSD · 4391 unmodified lines
43924392 Set the duration of ``osd-playing-msg`` in ms. If this is unset,
43934393 ``osd-playing-msg`` stays on screen for the duration of ``osd-duration``.
43944394
4395+``--osd-playlist-entry=<title|filename|both>``
4396+ Whether to display the media title, filename, or both. If the
4397+ ``media-title`` is not available, it will display only the ``filename``.
4398+
4399+ Default: ``title``.
4400+
43954401 ``--osd-bar-align-x=<-1-1>``
43964402 Position of the OSD bar. -1 is far left, 0 is centered, 1 is far right.
43974403 Fractional values (like 0.5) are allowed.
DOCS/man/osc.rst+0−7
@@ -408,13 +408,6 @@ Configurable Options · 407 unmodified lines
408408 Whether to display the chapters/playlist at the OSD when left-clicking the
409409 next/previous OSC buttons, respectively.
410410
411−``playlist_media_title``
412− Default: yes
413−
414− Whether to display playlist entries in media titles. If set to ``no``, file
415− names are used instead. Note that media title of a file is only available
416− once it has been loaded.
417−
418411 ``chapter_fmt``
419412 Default: ``Chapter: %s``
420413
options/options.c+3−0
@@ -862,6 +862,9 @@ static const m_option_t mp_opts[] = { · 861 unmodified lines
862862 {"osd-msg2", OPT_STRING(osd_msg[1]), .flags = UPDATE_OSD},
863863 {"osd-msg3", OPT_STRING(osd_msg[2]), .flags = UPDATE_OSD},
864864
865+ {"osd-playlist-entry", OPT_CHOICE(playlist_entry_name,
866+ {"title", 0}, {"filename", 1}, {"both", 2})},
867+
865868 {"video-osd", OPT_BOOL(video_osd), .flags = UPDATE_OSD},
866869
867870 {"idle", OPT_CHOICE(player_idle_mode,
options/options.h+1−0
@@ -259,6 +259,7 @@ typedef struct MPOpts { · 258 unmodified lines
259259 char *status_msg;
260260 char *osd_status_msg;
261261 char *osd_msg[3];
262+ int playlist_entry_name;
262263 int player_idle_mode;
263264 char **input_commands;
264265 bool consolecontrols;
player/command.c+8−3
@@ -3262,8 +3262,10 @@ static int mp_property_playlist(void *ctx, struct m_property *prop, · 3261 unmodified lines
32623262
32633263 for (int n = 0; n < pl->num_entries; n++) {
32643264 struct playlist_entry *e = pl->entries[n];
3265+ res = talloc_strdup_append(res, pl->current == e ? list_current
3266+ : list_normal);
32653267 char *p = e->title;
3266− if (!p) {
3268+ if (!p || mpctx->opts->playlist_entry_name > 0) {
32673269 p = e->filename;
32683270 if (!mp_is_url(bstr0(p))) {
32693271 char *s = mp_basename(e->filename);
@@ -3271,8 +3273,11 @@ static int mp_property_playlist(void *ctx, struct m_property *prop, · 1 unmodified line
32713273 p = s;
32723274 }
32733275 }
3274− const char *m = pl->current == e ? list_current : list_normal;
3275− res = talloc_asprintf_append(res, "%s%s\n", m, p);
3276+ if (!e->title || p == e->title || mpctx->opts->playlist_entry_name == 1) {
3277+ res = talloc_asprintf_append(res, "%s\n", p);
3278+ } else {
3279+ res = talloc_asprintf_append(res, "%s (%s)\n", e->title, p);
3280+ }
32763281 }
32773282
32783283 *(char **)arg =
player/lua/osc.lua+11−6
@@ -56,7 +56,6 @@ local user_opts = { · 55 unmodified lines
5656 livemarkers = true, -- update seekbar chapter markers on duration change
5757 chapters_osd = true, -- whether to show chapters OSD on next/prev
5858 playlist_osd = true, -- whether to show playlist OSD on next/prev
59− playlist_media_title = true, -- whether to use media titles as playlist entry names
6059 chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable
6160 unicodeminus = false, -- whether to use the Unicode minus sign character
6261
@@ -525,14 +524,20 @@ local function get_playlist() · 462 unmodified lines
525524 end
526525
527526 local message = string.format('Playlist [%d/%d]:\n', pos, count)
527+ local show = mp.get_property_native('osd-playlist-entry')
528528 for _, v in ipairs(limlist) do
529− local title = v.title
530− local _, filename = utils.split_path(v.filename)
531− if not user_opts.playlist_media_title or title == nil then
532− title = filename
529+ local entry = v.title
530+ if not entry or show ~= 'title' then
531+ entry = v.filename
532+ if not entry:find("://") then
533+ entry = select(2, utils.split_path(entry))
534+ end
535+ end
536+ if v.title and show == 'both' then
537+ entry = string.format('%s (%s)', v.title, entry)
533538 end
534539 message = string.format('%s %s %s\n', message,
535− (v.current and '●' or '○'), title)
540+ (v.current and '●' or '○'), entry)
536541 end
537542 return message
538543 end
player/lua/select.lua+11−1
@@ -28,9 +28,19 @@ end · 27 unmodified lines
2828 mp.add_forced_key_binding(nil, "select-playlist", function ()
2929 local playlist = {}
3030 local default_item
31+ local show = mp.get_property_native("osd-playlist-entry")
3132
3233 for i, entry in ipairs(mp.get_property_native("playlist")) do
33− playlist[i] = select(2, utils.split_path(entry.filename))
34+ playlist[i] = entry.title
35+ if not playlist[i] or show ~= "title" then
36+ playlist[i] = entry.filename
37+ if not playlist[i]:find("://") then
38+ playlist[i] = select(2, utils.split_path(playlist[i]))
39+ end
40+ end
41+ if entry.title and show == "both" then
42+ playlist[i] = string.format("%s (%s)", entry.title, playlist[i])
43+ end
3444
3545 if entry.playing then
3646 default_item = i

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t